Click here to Skip to main content

Arman S. - Professional Profile

8,038
Author
1,823
Authority
132
Debator
25
Editor
11
Enquirer
94
Organiser
711
Participant
No Biography provided
Member since Saturday, February 12, 2005 (7 years, 3 months)

For more information on Reputation please see the FAQ.
 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
  Refresh
GeneralTwo (or Too) Curious Java Language Bugs Pin
Tuesday, June 24, 2008 12:02 AM
Look at the following code sections. Each of them demonstrates a bug in Java language (5 and 6).
Both bugs are related to in-boxing/out-boxing problems.
 
// BUG #1
public class CuriousJavaBug1 {
	
	public static void main(String[] str) {
		Integer a = 100;
		Integer b = 100;
		Integer c = 200;
		Integer d = 200;
		System.out.println( a == b ); // true
		System.out.println( c == d ); // false 
	}
 
}
 
// BUG #2
public class CuriousJavaBug2 {
	// A nonsense from math's standpoint
	public static void main(String[] str) {
		Integer a = new Integer(100);
		Integer b = 100;
		System.out.println( a <= b ); // true
		System.out.println( a >= b ); // true
		System.out.println( a == b ); // false 
	}
 
}

 
--
=====
Arman

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web04 | 2.5.120528.1 | Last Updated 28 May 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid