Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. private static String input(String Message){
  2. Scanner input_scanner = new Scanner(System.in);
  3. System.out.print("n" + Message);
  4. String string = input_scanner.nextLine();
  5. input_scanner.close();
  6. return string;
  7. /*
  8. * An input function that prints out a message, then accepts an input
  9. */
  10.  
  11. Exception in thread "main" java.util.NoSuchElementException: No line found
  12. at java.util.Scanner.nextLine(Unknown Source)
  13. at main.learn.input(learn.java:25)
  14. at main.learn.main(learn.java:13)
  15.  
  16. String string = "";
  17. if (input_scanner.hasNextLine()) {
  18. string = input_scanner.nextLine();
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement