File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about wraper classes

 
sambasivarao laghuvarapu
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In the above code, why is it returning "true"?.

Thanks
 
Henry Wong
author
Marshal
Pie
Posts: 20829
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sambasivarao laghuvarapu:

In the above code, why is it returning "true"?.

Thanks


First, your code doesn't compile. You have problems with the braces.



Second, after fixing the braces, the code returns "false".

Henry
 
sambasivarao laghuvarapu
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry it was wrong from my end. My intention was - Why it is returning "false"?

Thnaks
 
Henry Wong
author
Marshal
Pie
Posts: 20829
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sambasivarao laghuvarapu:
Sorry it was wrong from my end. My intention was - Why it is returning "false"?

Thnaks


It is returning false because the wrapper classes define equality as having the same type and value. The objects that you are comparing are not the same type.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic