The moose likes Java in General and the fly likes string and string buffers? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "string and string buffers?" Watch "string and string buffers?" New topic
Author

string and string buffers?

senthil sen
Ranch Hand

Joined: Oct 10, 2002
Posts: 182
string sq="String object1"+String object2"
here there are 2 objects created
stringbuffer sq="String object1"+String object2"
well since string buffers are growable these two string objects are placed in the string buffer object.
what happens in the string object above??
Pete Harris
Ranch Hand

Joined: Feb 05, 2003
Posts: 39
Originally posted by senthil sen:
string sq="String object1"+String object2"
here there are 2 objects created

Here, there is 1 object created, containing the String "String object1Stringobject2" (ignoring the typo).
Originally posted by senthil sen:

stringbuffer sq="String object1"+String object2"
well since string buffers are growable these two string objects are placed in the string buffer object.

This fails to compile as String and StringBuffer are incompatible types.
senthil sen
Ranch Hand

Joined: Oct 10, 2002
Posts: 182
if
String s1= "Stringobj1"+Stringobj2";
does s1 carry \both the string object?
will it make stringobj1 and stingobj2 as one object??explain??
And why is that stringbuffer is not compatible to string object???explain
 
 
subject: string and string buffers?
 
Threads others viewed
what is this??
Inheritance and incomptaible casting
Help with assigning references
Serialization of strings
incorrect answer
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com