I was developing a program on hashset in which I have override the hashcode() and equals() but why we need to override ,If I make them as a comment in my pojo then the result of the hashmap did not come correct ..!!
can you guys after studying my short program , can explain the functionality of hashcode() and equals() with context to this program also, and general also..that will be a great help..!!
Just comment out overriding equals and hashcode method and execute your program. You will come know.
ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Saral, you really should try to find answers to your questions in publicly available resources first. Firstly, you'll learn what you need much sooner than when you to wait for someone here to answer your questions, and secondly, you'll learn how to find, use and utilize the existing documentation. Though it may seem trivial, some practice is needed to search for (and orientate oneself in) available resources. If you plan to earn a living as a software developer, this skill is indispensable.
It is possible that some things are still unclear even after reading the documentation and a tutorial or two. In this case, we'll be very glad to help. You'd ideally post links to materials you've read and pointed out the unclear parts. Asking smart questions is not only beneficial to you, but also to other users here at Javaranch.