This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about references

 
vara prasad
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i find references(in terms of address) of any String or any object?
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
volsteni raj
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic