File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String Buffer question