• 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

Possible errata OCP Java SE 11 study guide - page 59

 
Greenhorn
Posts: 11
2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On page 57, the second sentence in the first paragraph reads, " These are not local variables". This refers to method parameters.

On page 59, the 3rd sentence on line 2 going onto 3, of the 1st paragraph reads," The piecesOfCheese variable is a method parameter and, as discussed earlier, it is also a local variable."

These are two contradictory statements.

xoxoxo
 
Marshal
Posts: 79508
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please look in the Java® Language Specification. I can't remember what it says, but I think that local variables and parameters are regarded as distinct. There are, however, similarities to their behaviours.
 
author & internet detective
Posts: 41933
910
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've added it to the errata. This is tricky. In the Java 8 version of the book, we often treated local variables and method parameters as if they were the same. Both have the same rules for garbage collection and variable scope. (page 59 is in the variable scope section).

However, in Java 11, we also cover local variable type inference. (this is on page 57 among other places). With local variable type inference, it actually has to be a local variable so this distinction now matters.

Good catch Riffath!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic