• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Implementation of Stringobject and StringBuffer object  RSS feed

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

Can anybody tell me the implementation of 'Stringobject' and 'StringBuffer object'alongwith its functionality and usage in the program


looking forward

tx
venkat(hunt:scjp1.4)
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um .... right. You can download the source code for the JDK and look at String and StringBuffer's implementation if you really want, for some bizarre reason.
 
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I think these links will help you.
StringBuffer
String and StringBuffer
 
Krishna Srinivasan
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I hope these links will help you.
StringBuffer
String and StringBuffer
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you know which methods belong to String, e.g., concat() and which to StringBuffer, e.g., append(). Remember that the substring(int beginIndex, int endIndex) uses a zero-based beginIndex but starts with 1 for the endIndex - (and has en evil lower-case 's' in substring).

But most of all, understand the difference between Strings - immutable objects - and StringBuffers - not-so-immutable objects.
i.e.:
String s = new String ("Java");
s.concat(" Rules!");
System.out.println(s);
StringBuffer sb = new StringBuffer("Java");
s.append(" Rocks!");
System.out.println(sb);

output:
Java
Java Rocks

why?
The line of code
s.concat(" Rules!");
created a new String "Java Rules!", but didn't attach a reference to it!

Have fun.

Rob
SCJP 1.4
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!