View Single Post
  #8 (permalink)  
Old 12-31-2007, 07:21 AM
CaptainMorgan's Avatar
CaptainMorgan CaptainMorgan is offline
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
Quote:
Originally Posted by spoon! View Post
No. There is no such thing in Java. All objects are on the heap.
Excuse me? I believe you have a misunderstanding. There are, absolutely, local variables in Java, and
Code:
String a = "Java String";
is definitely a local variable assignment, thus placing it within the scope of the current method. Methods live on the stack, thus the method's local variables also live within the stack.See here for more on variables.
Quote:
When you do "new String(...)", it creates a new String object that is not the same as any other object, so it is guaranteed not to be == to another object.
Did you misread my post? I stated that the statement using new creates an object. What do you believe new is for? Simply put, creating new objects.

Last edited by CaptainMorgan : 12-31-2007 at 07:24 AM.
Reply With Quote