0

CharSequence[] に変換しようとすると、このエラーが発生し続けます。

メソッド toArray(CharSequence[]) は String 型に対して未定義です

これは私のコードです

              CharSequence[] cs = abbrev.toArray(new CharSequence[abbrev.length()]);

略語は文を最初の文字に分割するだけです (Hello World --> HW)

       String[] result = matches.toString().split("\\s+");
        // The string we'll create

        String abbrev = "";

           // Loop over the results from the string splitting
           for (int i = 0; i < result.length; i++){

               // Grab the first character of this entry
               char c = result[i].charAt(0);

               // If its a number, add the whole number
               if (c >= '0' && c <= '9'){
                   abbrev += result[i];
               }

               // If its not a number, just append the character
               else{
                   abbrev += c;
               }
           }

何か案は?

ありがとう

4

2 に答える 2

0

aはであるため、 aStringを aに変換する必要はありません。オブジェクトをオブジェクトに割り当てるだけで、変換は暗黙的です。詳細については、こちらを参照してください:文字列を CharSequence に変換する方法は?CharSequenceString CharSequenceStringCharSequence

于 2015-02-24T19:21:02.763 に答える