-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 "";
}
}
결과 >> 샌드위치 거짓 샌드위치하지변환 연결된 문자 (문자)
리터럴 문자열로 문자의 연결된 '문자열을'변환하는 방법이 있나요?
'System.out.println (word.equals (newWord)); '사용 – cpx
감사합니다,하지만 이것은 작동하지 않는 예제입니다. 변경된 문자열은 문자열 리터럴과 동일하지 않으므로 .equals()는 해당 문자열을 동일한 것으로 인식하지 않습니다. – Richard
당신이하고 싶은 것을 보여줄 수 있습니까? [ideone] (http://ideone.com/)을 시도하십시오. – cpx