This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "static : Bug in K&B P-145" Watch "static : Bug in K&B P-145" New topic
Author

static : Bug in K&B P-145

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
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".


Matt
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, (...)


Yours,
Bu.


all events occur in real time
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: static : Bug in K&B P-145
 
Similar Threads
using public class in other packages
Array Question
class Temp1 { int d[]; int a[]={43,34,344}; d=a; } what is the problem in the given code
nested comments
javac and classpath doubt