Hello,
I have the following problem, the method nextInt () of class acts java.util.Scanner not the way I expect this, Short cut in the program my problem is summarized.
Code:
import java.util.* ;
class tst (public static void main (String [] args)
(scanner snc = new scanner (System.in);
while (true) (int x = 0; System.out.println ("Choose 1,2,3 ");
snc.nextLine String str = ();
try (x = Integer.parseInt (str);)
catch (Exception e) (System.out.println (str +" Failure ");)
if ( x == 1) (System.out.println ("nerf");) if (x == 2) (System.out.println ("Please enter age");
int j = snc.nextInt ();
system. out.println ("2");) if (x == 3) (System.out.println ("Exit") System.exit (0);))))
I am getting any error in this code, but do no know why. Please help me with this. Thank you.
Bookmarks