This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes about references Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "about references" Watch "about references" New topic
Author

about references

vara prasad
Ranch Hand

Joined: Dec 21, 2004
Posts: 47
How can i find references(in terms of address) of any String or any object?
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
All objects are refered to with a reference. So when you declare

String str = "Hello, World!";

This is a reference named str that refers to a String object. In Java, you never manipulate objects directly. However, I don't think it's possible to get the phyiscal address and manipulate it. In fact, the lack of pointer arithmetic is one of the purported strengths of Java. Can you explain what prompted this question? What are you trying to do exactly? Hopefully we can give some more detailed advice if you provide a clear explanation.

Keep Coding!

Layne


Java API Documentation
The Java Tutorial
volsteni raj
Greenhorn

Joined: Jan 27, 2005
Posts: 3
Actually i want difference between
String str="vas";
String str1= new String("vas");

I came to known first Statement creates only one reference that is pointed out by str;
but for the second statement I find that String Literal vas is referenced by something and that something is referenced by str1;

So for that i place that query.

Any where thanks for ur reply
Preetham Chandrasekhar
Ranch Hand

Joined: Nov 05, 2003
Posts: 98
The second one creates a string object which is assigned to the string literal and then the variable str references the object to which the string literal is assigned to


"In theory, there is no difference between theory and practice. But, in practice, there is."<br /> - Jan L.A. van de Snepscheut
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: about references
 
Similar Threads
casting applied to references
resources for JSF
SCDJWS certification
invoking an action from a JSP page
AOP Patterns