Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in this snippet

 
Java Lover
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class Work1
{
public static void main(String args[])// throws Exception
{
int x =44;

System.out.println(x==x);
}
}

Hi

The output of the above code is:
true

And I want make it as: false


Rule:

1.Change any data type or anything in declaration of the variable.
2.no more changes is System.out.println statements
3.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15367
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Java Lover", please check your private messages. You can see them by clicking My Private Messages.
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One hint: doubles and floats have some special values that are not "real" numbers. You can find them in the Double and Float classes. Check those out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic