Win a copy of Pragmatic AI this week in the Artificial Intelligence 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Method with name long. Sybex OCA Java 8 Study Guide  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In book "OCA Oracle Certified Associate Java SE 8 Programmer I Study Guide" there is an error on page 170 in the next code


The method cannot have name 'long' because it is a reserved word in Java (unless one of the letters is not from english alphabet, but it this case it should be mentioned in the description for this code).
 
Ranch Hand
Posts: 206
27
Java jQuery Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Artem Petrov wrote:In book "OCA Oracle Certified Associate Java SE 8 Programmer I Study Guide" there is an error on page 170 in the next code


The method cannot have name 'long' because it is a reserved word in Java (unless one of the letters is not from english alphabet, but it this case it should be mentioned in the description for this code).



This typo have already logged in errata page
 
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
Hi Artem Petrov,

First of all, a warm welcome to CodeRanch!

Artem Petrov wrote:The method cannot have name 'long' because it is a reserved word in Java (unless one of the letters is not from english alphabet, but it this case it should be mentioned in the description for this code).


You are absolutely spot-on! You can't use Java keywords as identifiers (for methods, variables, classes,...). Don't forget: Java is case-sensitive, so long and lOng are two different names. The first one is not allowed as identifier, the second compiles without any problem.So the above code snippet should beOr intMethod and longMethod would be fine as well.

As Mushfiq already mentioned, this errata item was already added to the official list (which you can find here).

Hope it helps!
Kind regards,
Roel
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!