• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Bear Bibeault
  • paul wheaton
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Mikalai Zaikin
  • Piet Souris
Bartenders:

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: 78438
374
  • 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: 41763
885
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!
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic