Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Missing information in OCAJP Java 8 Jeanne Boyarsky and Scott Selikoff study guide - page 73  RSS feed

 
Javid Azimli
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think there are other 2 data types(double and float) and their wrappers that aren't supported by switch statement.

We should add them the sentence at page 73 as below:
"For the exam, we recommend you memorize this list. Note that float, double, boolean, long, and
their associated wrapper classes, are not supported by switch statements."
 
Charles O'Leary
Ranch Hand
Posts: 185
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javid,
Not a bad idea (I guess), but page 72

Prior to Java 5.0, this variable could only be int values or those values that could be promoted to int, specifically byte, short, char, or int.


and then goes on to explicitly bullet point
Data types supported
 
Charles O'Leary
Ranch Hand
Posts: 185
4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In other words, I don't think that it's "truly" missing, it just didn't get repeated.  Right?
 
Roel De Nijs
Sheriff
Posts: 11338
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a paragraph starting with "Data types supported", it's really obvious that all data types mentioned in the list are supported in a switch statements and all others are not. But if you make an additional note to mention data types which are not supported, I would list them all instead of arbitrarily choosing two of them. Because noiw the reader could be confused and be thinking: what about float and/or double? one of the lists is wrong here.

And honestly the quote of page 72 by Charles does not provide any useful information and the reader could still be in doubt. Because he knows that neither of the types boolean, long, float and double can be promoted to an int. So he's wondering why boolean and long are mentioned in the "not supported" list; but float and double are not.
 
Charles O'Leary
Ranch Hand
Posts: 185
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

And honestly the quote of page 72 by Charles does not provide any useful information and the reader could still be in doubt.


For the record, I think I just made the same "error" that the authors made:  My intent with the quote wasn't to "duplicate" the bulleted items, but to highlight where it was discussed in the book ... since you most likely need the book in your hand to determine if something is missing from it.

Roel,  I agree on all the points you (and implicitly Javid) raised!
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37222
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We chose to highlight boolean and long there because more people think those should be supported. (since there are a finite number of values). But yes, we could have explicitly repeated double and float.
 
Javid Azimli
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:We chose to highlight boolean and long there because more people think those should be supported. (since there are a finite number of values). But yes, we could have explicitly repeated double and float.


Yeap, I think it'd better to mention float and double explicitly together with boolean and long for clarity.Beginners may misunderstand.Thanks for reply.
 
Roel De Nijs
Sheriff
Posts: 11338
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:We chose to highlight boolean and long there because more people think those should be supported. (since there are a finite number of values).

Honestly you would be completely crazy to use a switch statement for boolean It requires so much more code to write than a simple concise if statementAnd what if you added the default case as well? Do you expect an "unreachable code" compiler error?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!