Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

The method append(String) is undefined for the type StringBuilder

807588Apr 1 2009 — edited Apr 3 2009
Hi,
I learned concept of StringBuilder but when I am trying this in my computer I found some errors which I post here in particular line commented.
public class StringBuilder {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder(); // creates empty builder, capacity 16
		sb.append("Greetings");  // The method append(String) is undefined for the type StringBuilder(adds 9 character string at beginning)


		int l = sb.length(); //The method length() is undefined for the type StringBuilder
		System.out.print("length is "+l);


	}

}
I tried with java 1.5 and java 1.6 aswell.
Pl tell anybody if know what is problem.

thanks,
Shobhit
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 1 2009
Added on Apr 1 2009
5 comments
7,319 views