This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes String Buffer question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "String Buffer question" Watch "String Buffer question" New topic
Author

String Buffer question

Latha Kota
Ranch Hand

Joined: Mar 13, 2003
Posts: 35
HI all, I came across this question in Whizlabs software.
StringBuffer s = new StringBuffer("abcd");
invoking length() of String class didnt give any errors i.e. s.length();
Does anybody know the reason. I thought that it cannot use the methods of String class.
Thanks in Advance,
Latha
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
s is a StringBuffer and StringBuffer has a length() method.
Where do you see String.length() being called in your example?
[ April 11, 2004: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Arun Sharma
Ranch Hand

Joined: Dec 24, 2003
Posts: 40
I am not sure what exactly your problem is. There is a length() method for StringBuffer and s here is a StringBuffer.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: String Buffer question
 
Similar Threads
StringBuffer Question
Again String.
A String Buffer question,help!
StringBuffer Question