File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static : Bug in K&B P-145 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "static : Bug in K&B P-145" Watch "static : Bug in K&B P-145" New topic

static : Bug in K&B P-145

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 392
At Page 145 (K& B book)

So, the way we access a static method (or static variable) is to use the dot operator on the class name, as opposed to using it on a reference to an instance.

Vishal K Patel
Ranch Hand

Joined: Oct 20, 2006
Posts: 43
static members can be accessed by the [instanse_name.static_member].

Neither compiler nor JVM complains about this.
But the resul remains same whether one use class name or instanse name.
Matt Russell
Ranch Hand

Joined: Aug 15, 2006
Posts: 165
At the bottom of that page, K&B say, "the Java language also allows you to use an object reference to access a static member".

Inquisition: open-source mock exam simulator for SCJP and SCWCD
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Hi cowboys,

this isn't a bug. One sentence before, it is said that
But this approach (using a reference to an object) isn't appropriate for accessing a static method, (...)


all events occur in real time
I agree. Here's the link:
subject: static : Bug in K&B P-145
It's not a secret anymore!