Insight

Monday, September 3, 2012

Java Puzzle

Java puzzle on equal and == comparision operators:


public
class Test {
public static void main(String[] args) {
int x = 7;
Integer y =
new Integer(7);
System.
out.println(x == 7);
System.
out.println(y.equals(x));
}
}

Output:

true
true
Posted by Geek at 7:44 AM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: Java puzzle

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2014 (4)
    • ►  January (4)
  • ►  2013 (9)
    • ►  December (7)
    • ►  November (1)
    • ►  January (1)
  • ▼  2012 (26)
    • ►  November (3)
    • ▼  September (22)
      • Eclipse IAdaptable pattern – Show Properties for I...
      • Chain of Responsibility Design pattern
      • Adapter Design Pattern
      • Comparable and Comparator in Java
      • Reference Objects and Garbage Collection
      • Database ACID Properties
      • Thread concepts
      • How run a JAR file
      • Swap 2 variables without using a temp variable
      • Big O Notation - Illustration
      • Basics of Big O Notation
      • Principles of Designing
      • Java Links
      • Classical operations on Set
      • Thread Puzzle
      • Avoiding dead locks
      • Java Puzzle
      • Singleton Design Pattern
      • Producer Consumer Problem
      • Thread Local Example
      • Reverse of single linked list
      • Dead lock using threads
    • ►  August (1)
Ethereal theme. Powered by Blogger.