Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The definition of value-based classes

 
Kamil Hlubek
Ranch Hand
Posts: 49
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someine explain this extract in one's own words, please.


A program may produce unpredictable results if it attempts to distinguish two references to equal values of a value-based class, whether directly via reference equality or indirectly via an appeal to synchronization, identity hashing, serialization, or any other identity-sensitive mechanism. Use of such identity-sensitive operations on instances of value-based classes may have unpredictable effects and should be avoided.


This extract comes from here.
 
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
Kamil Hlubek wrote:Could someine explain this extract in one's own words, please.

To be honest this seems waaaaaaaaay to complicated for the OCA exam. Is this something which was mentioned in one of the OCA8 study guides? Or did you just encounter it while browsing the internet?
 
Kamil Hlubek
Ranch Hand
Posts: 49
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, if I make a tour on the API I come always at complicated stuff out. After about 1 hour or two I notice then : "What? It felt like about half an hour" .

So the answer is: No I simply looked at the LocalDate class from the Java Date-Time API and there is written of course, that it is a value-based class.

Apparently your meaning, that I ask you, what are all the identy-sensitive operations, but my intend is to ask you to explain me the intention of the test only with the reference equality( == ), because the others are all marked as or, so they should not differ in the general working of the value-based classes in my opinion.
 
Henry Wong
author
Marshal
Pie
Posts: 22113
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The quote seems to be a convoluted way of comparing the equality operator versus the equals() method ... and basically say "use the equals() method for cases where the equality operator will not work"...

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic