-1
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner input = new Scanner(System.in) ;
int number = input.nextInt() ;
String word = input.nextLine();
String word1 = Integer.toString(number) ;
int number1 = Integer.parseInt(word) ;
if (number1 == Integer.parseInt(word))
{
number1 = number + 10 ;
System.out.println("Congratualtion its a number"+" "+ number1) ;
}
else if (word1 == Integer.toString(number))
{ word1 = 10 + word ;
System.out.println("Congratualtion its a word"+" "+ word1);
}
else
System.out.println("Something is wrong !!! ") ;
}
}
予期しないエラーを取得すると、エラーメッセージ:これは問題の行である
Error : Exception in thread "main" java.lang.NumberFormatException: For input string: " "
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:481)
at java.lang.Integer.parseInt(Integer.java:527)
at Solution.main(Solution.java:13)
** NumberFormatException:入力文字列の場合: "** **これに気付きましたか?データを正しく入力してください。 – developer
予期しない理由は何ですか?別のエラーが予想されましたか? – shmosel