long을 문자열로 변환하고 그것이 회문인지 확인하는 프로그램을 작성하려고합니다. 이제까지 다음을 작성했지만 호환되지 않는 유형 오류가 발생합니다. 나는 그것을 일으키는 원인을 찾을 수없는 것 같습니다. : S 어떤 도움이 많이 주시면 감사하겠습니다 :)Palindrome을 확인하는 프로그램
을 오류가 라인 (24)에서 발생하며 호환되지 않는 유형을 말한다 - 무효 찾았지만 java.lang.String의
예상public class programPalindrome
{
private String go()
{
Input in = new Input();
System.out.print("Enter Number: ");
return in.nextLine();
long number = in.nextLong();
String Palindrome = Long.toString(number); // converts the long into a string
String newAnswer = reverse(Palindrome);
String anotherAnswer = reverseCheck(Palindrome,newAnswer);
System.out.println("This is a Palindrome" + Palindrome);
}
// Check to see if the two argument Strings are the reverse of each
// other.
private String reverseCheck(String Palindrome, String newAnswer)
{
if (Palindrome.compareTo(newAnswer) == 0) {
return System.out.println("It is a palindrome");
}
else
{
return System.out.println("It is not a palindrome");
}
}
// Return a String which is the reverse of the argument String
private String reverse(final String Palindrome)
{
String result = new String();
int position = 0;
while (position < Palindrome.length())
{
result = new Character(newAnswer.charAt(position)).toString() + result;
position = position + 1;
}
return result;
}
public static void main(String[] args)
{
new programPalindrome().go();
}
}
스택 추적을 게시 할 수 있습니까? – vicatcu
오류 메시지와 오류가 발생한 행을 추가하십시오. –
컴파일 오류가 어디서 발생합니까? stackTrace를 추가 할 수 있습니까? – Luhar