Problem with startsWith()

Hi allDoes anyone know why i might be getting a compile error when i try and use startsWith()? Im using it like this:s2 = "Hello"StringBuffer sbuf = new StringBuffer(reply);if((b = sbuf.startsWith(s2)) == true)...
[255 byte] By [java_newbea] at [2007-11-26 13:35:10]
# 1
Yes, StringBuffer doesn't define a method called startsWith
dannyyatesa at 2007-7-7 22:17:56 > top of Java-index,Core,Core APIs...
# 2

It's an extremely important skill to learn to read the API and become familiar with the tools you will use to program Java. Java has an extensive set of [url=http://java.sun.com/javase/reference/api.jsp]online documentation[/url] that you can even [url=http://java.sun.com/docs/index.html]download[/url] for your convenience. These "javadocs" are indexed and categorized so you can quickly look up any class or method. Take the time to consult this resource whenever you have a question - you'll find they typically contain very detailed descriptions and possibly some code examples.

[url=http://java.sun.com/javase/reference/api.jsp]Java?API Specifications[/url]

[url=http://java.sun.com/javase/6/docs/api/]Java?SE 6 JDK Javadocs[/url]

Also, your boolean expression is unnecessarily complicated:

// if((b = sbuf.startsWith(s2)) == true)

if (s.startsWith(s2))

~

yawmarka at 2007-7-7 22:17:56 > top of Java-index,Core,Core APIs...
# 3
@java_newbe:This forum is for questions and discussions about Java Generics only. Please match your posts to the forum subject in the future. If you don't know which forum to post to, Use the New to Java forum.
ChuckBinga at 2007-7-7 22:17:56 > top of Java-index,Core,Core APIs...
# 4

> @java_newbe:

> This forum is for questions and discussions about

> Java Generics only. Please match your posts to the

> forum subject in the future. If you don't know which

> forum to post to, Use the New to Java forum.

to clarify, Generics is a feature present from java 1.5 onwards. this is a forum about them, not a forum for generic questions. as chuck said, post in the right forum - you'll get a better response

georgemca at 2007-7-7 22:17:56 > top of Java-index,Core,Core APIs...