• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Boolean statement Temperature Class Java

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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/
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
reply
    Bookmark Topic Watch Topic
  • New Topic