Help on HashCode
1. I came to know that for every
object created there will be an hashcode assigned. is that anything concerned
with
Yeah, a hashcode is assigned for
every object created. Identity and value of an Object are 2 important
properties among others. Value may be the contents/state of the Object,
Identity is that property of the Object using which you can distinguish
Hashcode is used to find objects in data structures such as Hashtable etc(There are also other identity based uses for it). The designers of the language anticipated that collections like Hashtable will be used a lot by programmers and provided a easy way to compute hashcode. There's lot more to it, try google'ing
on hashcode() and equals().
2, Also when ever im printing an
object of a class itz string representation is like this classname@23e45g
When you pass an Object to System.out.println what it prints is the return value of the toString method of that object. The above string representation which you have pasted is the default implementation of the toString() method in the Object class. What you see is simple, its nothing
but a concatenation of three things:
The name of the class can be obtained by using the getName() method on the Object's Class object. You can obtain the class object for any object by invoking the getCLass() method. The implementation is simple: public String toString() {
Vinay.
Related:
Java Certification, Programming, JavaBean and Object Oriented Reference Books Return to : Java Programming Hints and Tips All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
|