Apr 15, 2006
56,639
Any of you peeps want to help a honkey out with his Java? I've to explain what and why a code segment will output.



My answer was marked as incomplete;

/**Following on from both segments, the third segment creates the memory reference 'Hello World'.
* It then assigns the 'mystring2' string the same memory reference.
/* As a result, it will display 'M3 The two strings are equal */

Any help would be much appreciated.
Thanks for reminding me why I hated college.

- - - Updated - - -

Got about 3 hours sleep last night and I've been working for more than 12 hours since I woke up. I think I'm gonna pass out in a bit.
I woke up at 9 this morning. And I started feeling super sleepy at 7! :groan: Now I'm going out for drinks. God help me!
 

Martin

Senior Member
Dec 31, 2000
56,913
Any of you peeps want to help a honkey out with his Java? I've to explain what and why a code segment will output.



My answer was marked as incomplete;

/**Following on from both segments, the third segment creates the memory reference 'Hello World'.
* It then assigns the 'mystring2' string the same memory reference.
/* As a result, it will display 'M3 The two strings are equal */

Any help would be much appreciated.
Incomplete? The nerve.

Your terminology is a bit confused, I don't know what you mean by "segment" or which one is supposed to be "the third".

Line 2 creates a string.
Line 3 creates another string.

mystring1 and mystring2 are different objects, so the predicate in the if evaluates to false.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 717)