I don't agree with the explanation here. "dereferencing" actually refers to the process of getting or setting the value referred to by a reference. For example, If I say String s = "hello" then s is a reference to the actual characters. In this case I can dereference s to get the characters, but if I say, for example String s = null; then I can't dereference s, because it does not refer to any characters - it is null! In the case of the initial question, I would imagine that the code was trying to call a method on a byte, and as byte is a primitive type which contains its own value, and not a reference to an Object, it could not be dereferenced. For example: byte b = 45; System.out.println(b.toString()); will not work (if you need to call a method, you should have used the object wrapper class Byte, instead), and neither will byte b; b = 23; where the  have inadvertently omitted from an array declaration.
In general, Reference is an address to some object/variable, While getting or setting value for that variable you need to de-reference that (means you need to get to that location where it is actually laying in the memory). Dereference is a common operation done by C++ programers. Hope this will clear Dereferencing.
Heya Frank - Thanks for your post. I don't use this particular term myself except by accident, partly because I've heard it used both ways with equal vigor and confidence. Judging only by the way I've most often seen it used, deferencing meaning "setting to null" seems the popular meaning for Java. Dereferencing meaning "get the value of" sounds suspiciously like C/C++ semantics. ------------------ Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide [This message has been edited by Michael Ernest (edited February 20, 2001).]
Make visible what, without you, might perhaps never have been seen. - Robert Bresson
Believe me, using "dereference" to mean "set to null" is a misconception. You won't find it anywhere in any official Java documents. If you have encountered it a lot, that just means it is a popular misconception
Yep, dereferencing is the action of retrieving the value pointed to by a reference. Have a look at the Online Dictionary of Computing [This message has been edited by Graeme Brown (edited February 22, 2001).]
From Frank: Believe me, using "dereference" to mean "set to null" is a misconception. You won't find it anywhere in any official Java documents. If you have encountered it a lot, that just means it is a popular misconception
Agreed!!! Java does not allow dereferencing does not redefine the term "dereferencing". Roseanne
This is in C++ language: Object* pObj = new Object(); // equivalent to java: Object obj = new Object(); // you can see obj in Java actually is a pointer // that is why there is a NullPointerException in Java Object** ppObj = &pObj; // dereferencing the Object address // or find out where you store the Object address // pointer of pointer in C++ // There is no Java equivalence to it. Java is a lot safer than C++ because of it, but less powerful to certain extent. Thanks! Roseanne Join our SCJD Study Group when certified
[This message has been edited by Roseanne Zhang (edited February 22, 2001).]
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop