If you Directly print any object of Person It will the ClassName@HashCode
to the Code.
in your case com.foo.Person@2f92e0f4
is getting printed . Where Person
is a class to which object belongs and 2f92e0f4
is hashCode of the Object.
public class Person {
private String name;
public Person(String name){
this.name = name;
}
// getter/setter omitted
@override
public String toString(){
return name;
}
}
Now if you try to Use the object of Person
then it will print the name
Class Test
{
public static void main(String... args){
Person obj = new Person("YourName");
System.out.println(obj.toString());
}
}