How to convert string to charSequence ?

i have code like

String tdTargettext = tdTerms[j][1].getText();

if(targetSegment.contains(tdTargettext.subSequence(0,tdTargettext.length())))

{

}

I want to use string into contains method which accepts only charsequence

[260 byte] By [AmitChalwade123456a] at [2007-11-27 10:19:53]
# 1

String is a charSequence. That is to say it implements the charSequence interface. Anyplace that calls for a charSequence variable can take a String. Read the String API and you'll see this is true.

petes1234a at 2007-7-28 17:00:22 > top of Java-index,Java Essentials,Java Programming...
# 2

huh? Write clear and correct English Strings and maybe someone will understand your question.

jwentinga at 2007-7-28 17:00:22 > top of Java-index,Java Essentials,Java Programming...
# 3

[code]

String tdTargettext = tdTerms[j][1].getText();

CharSequence ch=tdTargettext;

if(targetSegment.contains(ch.subSequence(0,ch.length())))

{

}

[/code ]

For Above code it is giving:::java.lang.NoSuchMethodError: java.lang.String.contains(Ljava/lang/CharSequence;)Zthis error

Suggest Solution

Thanks

AmitChalwade123456a at 2007-7-28 17:00:22 > top of Java-index,Java Essentials,Java Programming...
# 4

OK, now we're getting somewhere. First off:

1) what is targetSegment? You show a call to its contains method but you don't define it anywhere in your code sample. This is the source of your error, so don't you think it would be important to show it?

2) Based on the error message snippit, I'm guessing that targetSegment is a String. If so, have you looked up the String api (or the charSequence api for that matter)? What does it tell you about the "contains" method?

Answer these questions and maybe I can help you further.

Also perhaps you could try a variation on the String method regionMatches.

Message was edited by:

petes1234

petes1234a at 2007-7-28 17:00:22 > top of Java-index,Java Essentials,Java Programming...