I am try to compare contents of class object with equals(),but it not give desired output.
so,
How to override equals method in java to desired output ?
Please help me with example...
I am try to compare contents of class object with equals(),but it not give desired output.
so,
How to override equals method in java to desired output ?
Please help me with example...
Jump to PostUhm, by defining an "equals(Object o)" method in your own class?
Uhm, by defining an "equals(Object o)" method in your own class?
Please check this class
class A{
int x;
A(int x){
this.x=x;
}
}
class test11{
public static void main(String as[]){
A a=new A(12);
A a1=new A(12);
System.out.print(a.equals(a1));
}
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.