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

Possible errata on p54 about Java primitives & String? (Java OCA 8 Programmer I Study Guide, Sybex)

 
Juliet Smith
Greenhorn
Posts: 9
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
3rd last paragraph on p. 54 reads:
All of the arithmetic operations may be applied to any Java primitives, except boolean and String.


Table 1.1 on p. 21 lists the Java primitive types - however String is not listed as a primitive.

Even though String is treated specially, it isn't a primitive - as far as I know
 
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
Juliet Smith wrote:Table 1.1 on p. 21 lists the Java primitive types - however String is not listed as a primitive.

Even though String is treated specially, it isn't a primitive - as far as I know

You are correct! Although String literals are treated in a special way, String is definitely not a primitive. It's not listed as one of the Primitive Data Types.

Hope it helps!
Kind regards,
Roel
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good find. Have a cow. I've added this to the errata.
 
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
Just for the record (and completeness): the + operator will work on String, but will not perform addition (like with two ints), but concatenation. So for all primitives (except boolean) the + is an arithmetic operator for addition (and that's including chars!), and for Strings it's a concatenation operator for (obviously) concatenating.

Pop quiz question time! Do you know the output of this code snippet? And "yes" or "no" is not a valid answer

Hope it helps!
Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic