3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by ~s.o.s~
0

The first one basically reads as follows :
"Create a string object called S where S refers to the statically defined string object "abc".

The second one reads as follows :
"Create a string object called S, where S points to a new dynamically allocated string object with the value 'abc' "

Use the first one when you can.

Edited by firstPerson: n/a

0

The first one basically reads as follows :
"Create a string object called S where S refers to the statically defined string object "abc".

The second one reads as follows :
"Create a string object called S, where S points to a new dynamically allocated string object with the value 'abc' "

I'm afraid that kind of simplicity won't work when explaining the concept of String pools in Java.

What is the difference between

String s="abc" and

String s=new String("abc");

Read this thoroughly.

Edited by ~s.o.s~: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.