Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Sybex CSG 11: Errata in the OCP Java SE 11 Developer Complete Study Guide

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The format() and parse() methods of the NumberFormat class are not static methods of this class as suggested on pages 774 and 775 of the study guide. This suggestion is made in the following quoted remarks from the study guide: "The NumberFormat.format() method formats the ..." (on page 774) and "The NumberFormat.parse() method accomplishes this ..." (on page 775).
 
Marshal
Posts: 26519
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's quite common to describe methods in that way, rather than having to say "The format() method of the NumberFormat class..." Usually that phrasing isn't intended to imply that the methods described in that way are static. (You'll note that the text doesn't explicitly say they are static.)
 
Nyeng Gyang
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for responding to my post.

It is my considered opinion that describing methods in this way, which you say is quite common, is a convention that is both confusing and inefficient. Let me speak for myself, at least, as follows: Before I saw those methods being described, as though they are static methods of the NumberFormat class, using a means you inform is a convention for describing methods, I had already checked the official Java documentation and known that they are instance methods. This confused me, hence the confusion caused by this bizarre convention. Consequently, I had to expend some to ensure that the methods are truly instance and not static methods; this was not a useful utilization of those minutes I spent making this confirmation, hence the inefficiency of the bizarre convention.

Even though I already know the kind of error the Java compiler reports for invoking a non-static method from a static context (including either from a static method or by a class), after reading your response, I nonetheless ran code to confirm that the compiler is going to report the same (or similar) error if I invoked one of these instance methods by the NumberFormat class and obtained the following confirmation of my conjecture:
In short, the convention to describe instance methods the way they have described in the study guide here is not a useful one, but that is my own opinion, of course.
 
Paul Clapham
Marshal
Posts: 26519
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nyeng Gyang wrote:It is my considered opinion that describing methods in this way, which you say is quite common, is a convention that is both confusing and inefficient.



I can certainly agree with that, at least with the "confusing" part. I would agree with you that it would be worthwhile for the authors of the guide to avoid that usage and say "the format() method of the NumberFormat class" instead. However I've described non-static methods in the "confusing" way myself, including here on the forums, so you should expect to see it in casual usage.
 
reply
    Bookmark Topic Watch Topic
  • New Topic