Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Possible errata OCP Java SE 11 study guide - page 59

 
Greenhorn
Posts: 11
2
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 71664
312
  • Mark post as helpful
  • send pies
  • 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: 40359
820
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • 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!
reply
    Bookmark Topic Watch Topic
  • New Topic