• Post Reply Bookmark Topic Watch Topic
  • New Topic

Boolean statement Temperature Class Java  RSS feed

 
gary zhong
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



here is my code, I am struggling at the boolean statement(t2 should be changeable but I have no clue to do it.)
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Please use code tags when posting.
I have added them fot you this time. Doesn't it look better?

I have also merged your two posts into one.
I hope you don't mind.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a long article but it's a very thorough discussion of how you would implement an equals() method: https://www.sitepoint.com/implement-javas-equals-method-correctly/
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There I was thinking what a good article, only I found
We’ll ignore String interning in this article; if this bugs you, assume every string literal were wrapped in a new String(...).)
on the first page. If they meant new String(...) why don't they write new String(...)? If anybody executes the code they show, it will print true. The comments show that caused no slight confusion to their readers.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I skipped over that and went right to the section about how to implement equals().  Should just automatically cite a search for Joshua Bloch on implementing equals
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following page about hash code was better. As well as Bloch, there are Angelika Langer's Java® equals and hashCode FAQs (please search and beware of finding only the German version ‍) and the first link in this Wiki page (=Odersky Spoon and Venners).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!