
class Person{
int age; String name; void talk(){ System.out.println("my name is:"+name); System.out.println("my age is:"+age); } } class Hash{ public static void main(String ar[]){ Person raju=new Person(); raju.name="raju"; raju.age=23; System.out.println("hash code is:"+raju.hashCode()); Person sita = new Person(); raju.name="sita"; raju.age=20; raju.talk(); } } if i run this prog i get only sita object details, y i cant get both raju and sita details

Hello,
We have modified your code.Check it:
class Person{
int age;
String name;
void talk(){
System.out.println("my name is:"+name);
System.out.println("my age is:"+age);
}
}
class Hash{
public static void main(String ar[]){
Person raju=new Person();
raju.name="raju";
raju.age=23;
raju.talk();
System.out.println("hash code is:"+raju.hashCode());
Person sita = new Person();
sita.name="sita";
sita.age=20;
sita.talk();
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.