Wed Oct 22, 2008 2:07 am
public class EqualsTest
{
public static void main (String [] args)
{
Moof one = new Moof(8);
Moof two = new Moof(9);
if (one.equals(two))
{
System.out.println("one and two are equal");
}
}
}
class Moof
{
private int moofValue;
Moof(int val)
{
moofValue = val;
}
public int getMoofValue()
{
return moofValue;
}
public boolean equals(Object o)
{
System.out.println(o instanceof Moof);
System.out.println(((Moof)o).getMoofValue());
System.out.println(this.moofValue); //XXX
if ((o instanceof Moof) && (((Moof)o).getMoofValue() == this.moofValue))
{
return true;
}
else
{
return false;
}
}
}
Wed Oct 22, 2008 2:08 am
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.