System.out.println (" Tomorrow it rains (ture / false):?");
Scanner in = new Scanner (System.in);
water = in.nextBoolean ();
if (water)
{
System.out.println (" in the internet cafe ! " ) ;
}
else
{System.out.println (" go hiking ! " ) ; }
}
}
After running into the output : it rains tomorrow , then ? (Ture / false): When the input ture, error
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor (Scanner.java: 909)
at java.util.Scanner.next (Scanner.java: 1530)
at java.util.Scanner.nextBoolean (Scanner.java: 1825)
at InputText.main (InputText.java: 22)
How to correct ? ? ? ? ? ? ? ? Thank
------ Solution ------------------------------------- -------
is true, is not ture, pay attention to your spelling
------ Solution -------------------- ------------------------
you enter the wrong Oh .
------ Solution ---------------------------------------- ----
brother, you have to enter true not enter ture ah !
------ Solution ---------------------------------------- ----
true ture I've often confused and maybe ------ For reference only ---------------------------- -----------
right. Newcomers. .
没有评论:
发表评论