• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equality with booleans

 
Jason Attin
Ranch Hand
Posts: 232
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, quick question from Glenn, Mitchell. OCAJP Oracle Certified Associate Java SE 8 Programmer Practice Exams (Kindle Location 18792). Enthuware. Kindle Edition.
This returns true . creates a new Boolean object but what does do? It doesn't create any object does it? SO we are comparing a Boolean object to what?
 
Henry Wong
author
Marshal
Pie
Posts: 22094
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jason Attin wrote:
This returns true .


Actually, this should return false. There is no way those two objects are the same object.

Henry
 
Jason Attin
Ranch Hand
Posts: 232
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, yes false, you're right. So what's that  Boolean.TRUE? does it create a new object?
 
Henry Wong
author
Marshal
Pie
Posts: 22094
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jason Attin wrote:So what's that  Boolean.TRUE? does it create a new object?


TRUE and FALSE are static variables of the Boolean class. They are assigned to Boolean objects, when the Boolean class is initialized.

Henry
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what do you think this code snippet will produce as output?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic