• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String Buffer question

 
Latha Kota
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Arun Sharma
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure what exactly your problem is. There is a length() method for StringBuffer and s here is a StringBuffer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic