-3
public class Tester{
public static void main (String args[]){
String word="sandwich";
char newWord[]=word.toCharArray();
System.out.println(word.equals(transform(newWord)));
if (word.equals(transform(newWord))){
System.out.println("same");}
else{
System.out.println("not");
}
}
public static String transform(char [] newWord){
for(int i=0; i<newWord.length;i++)
{
System.out.print(String.valueOf(newWord[i]));
//System.out.print(""+newWord[i]);
}
return "";
}
}
RESULT >>サンドイッチ偽 サンドイッチない変換連結文字(文字)
リテラル文字列に文字を連結した「文字列」を変換する方法はありますか?
'System.out.println(word.equals(newWord));' – cpx
ありがとうございますが、これはうまくいかない例です。変更された文字列は文字列リテラルと等価ではありません。したがって、equals()はそれらを等しいと認識しません。 – Richard
あなたは何をしようとしているかの例を挙げることができますか? [ideone](http://ideone.com/)を試してください。 – cpx