Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. public static int readInput() {
  2. int nr = -1;
  3. do {
  4.  
  5. if (scanner.hasNextInt()) {
  6. nr = scanner.nextInt();
  7. } else {
  8. System.out.println("\nTegemist ei ole numbriga.\nPalun sisestage number.\n\n");
  9. break;
  10. }
  11. } while (nr < 0);
  12. scanner.nextLine(); // read the rest of the line
  13. return nr;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement