publicclassTrivalTest_equals
{
publicString color;
publicString speed;
publicTrivalTest_equals()
{
}
publicTrivalTest_equals(String a,String b)
{
this.color=a;
this.speed=b;
}
publicstaticvoidmain(String args[])
{
TrivalTest_equals t1=newTrivalTest_equals("yellow","fast");
TrivalTest_equals t2=newTrivalTest_equals("yellow","fast");
if(t1.equals(t2))
{
System.out.println("the two objects are the same.");
}
else
{
System.out.println("the two are not the same ");
}
}
}
You cannot compare two example“ if(t1.equals(t2))”,it should be two exactly elements like string or number.