4 Replies Latest reply: Jul 12, 2007 1:36 AM by 807605 RSS

    How to convert string to charSequence ??

      i have code like

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


      I want to use string into contains method which accepts only charsequence
        • 1. Re: How to convert string to charSequence ??
          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.
          • 2. Re: How to convert string to charSequence ??
            huh? Write clear and correct English Strings and maybe someone will understand your question.
            • 3. Re: How to convert string to charSequence ??
              String tdTargettext = tdTerms[j][1].getText();
                               CharSequence ch=tdTargettext;
              [/code ]
              For Above code it is giving   :::java.lang.NoSuchMethodError: java.lang.String.contains(Ljava/lang/CharSequence;)Z    this error 
              Suggest Solution 
              • 4. Re: How to convert string to charSequence ??
                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: