Home arrow static arrow Java Programming [Archive] - Meeting trouble when retrieving a byte array.
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Meeting trouble when retrieving a byte array.
This topic has 47 replies on 4 pages.    « Previous | 1 | 2 | 3 | 4 |

Posts:536
Registered: 6/29/03
Re: Meeting trouble when retrieving a byte array.  
Aug 5, 2004 8:17 PM (reply 45 of 47)



 
Thanks, Kayaman,

So you mean the value like "[B@2aa02aa0" I retrieved is the hash code value and not the value of internal address?

Best regards,
George

 

Posts:196
Registered: 6/24/97
Re: Meeting trouble when retrieving a byte array.  
Aug 6, 2004 4:53 AM (reply 46 of 47)



 
What you retrieved is the hash code value, but because of the way hashcode values are calculated by the hashCode() method in java.lang.Object, it may also be the reference of the byte array.

But, to answer your original question:
a) You cannot access objects / primitives in java using pointer references. Java was DESIGNED to be that way to avoid problems

b) The value that you are printing out , for all practical purposes, is meaningless. You cannot use that value for any purpose

c) If what you are trying to implement is a reference to a reference, this is how you do it :

[code]

class A {
String hi = "Hello World";

public A() {
// wants to pass a reference to hi via A to B
B b = new B();
b.passTheBuck(this);
}

}

class B {

public void passTheBuck( A theBuck) {
System.out.println("The original string was " + theBuck.hi);
}

}

If you do reply to this post, please dont use the word "buddy" in it.

 

Posts:536
Registered: 6/29/03
Re: Meeting trouble when retrieving a byte array.  
Aug 6, 2004 11:33 PM (reply 47 of 47)



 
Thanks, freddi, I got it.

George

 
This topic has 47 replies on 4 pages.    « Previous | 1 | 2 | 3 | 4 |