public class Equl
{
public static void main(
String[] s)
{
Integer i=new Integer(78);
Long l=new Long(78);
Double d=new Double(78);
if(i.equals(l))
System.out.println("1");
if(l.equals(d))
System.out.println("2");
if(d.equals(i))
System.out.println("3");
if(i.equals(78))
System.out.println("4");
}
}
output is:4
why it is giving 4 as output.
wrapper classes are peers so first 3 methods nt executed.
equals method is used to
test whether two object are meaningfully equal or not.
but instead of object here we are passing 78 also it is not showing any problem...
why?
[ November 04, 2008: Message edited by: Ganeshkumar cheekati ]