aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes query in answer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "query in answer" Watch "query in answer" New topic
Author

query in answer

Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84



public class Test4 {
public static void main(String[] args) {
Test4 t = new Test4();
int i1 = 2000;
int i2 = 2000;
int i3 = 2;
int i4 = 2;
Integer Ithree = new Integer(2);
Integer Ifour = new Integer(2);
System.out.println(Ithree == Ifour);
t.methodA(i3,i4);
t.methodA(i1,i2);
}
public void methodA(Integer i, Integer eye){
System.out.println(i == eye);
}
}


so Answer would be :
false
true
false

I understand first two false and true but in last one is false how?

Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
i1==i2 or i==eye will return true only if their values are between -128 to 127 inclusive......else they will give false

this link will help you a bit too

http://www.coderanch.com/t/472339/Programmer-Certification-SCJP/certification/equals
Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
Thanks for reply.

Could you tell me, in which link this topic has mentioned?
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
wrappers.....k&B book
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

Also see here


http://muhammadkhojaye.blogspot.com/
 
 
subject: query in answer