• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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

 
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
 
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

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
 
author & internet detective
Marshal
Posts: 38659
677
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: 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
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!