Win a copy of Building Blockchain Apps 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
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

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: 68110
258
  • 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: 39890
798
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!
 
Is this the real life? Is this just fantasy? Is this a tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!