0

How get string input from user using scanner. e.g:

Scanner get = new Scanner(System.in);

String name = get.nextString(); 

But calling doesn't work with string but it works with integers or double data types.

alayor
  • 4,537
  • 6
  • 27
  • 47
  • `String name = get.nextString( );` Write types uppercase and don't forget the brackets at the end of a method call. – Schokokuchen Bäcker Mar 12 '17 at 15:57
  • try, String name = get.next() ; And for such minor issues please read your tutorial guides well before asking, java docs , tutorialspoint , javatpoint , are some good places if you want to learn. – Ashish Sharma Mar 12 '17 at 16:05
  • Possible duplicate of [Getting User input with Scanner](http://stackoverflow.com/questions/12999899/getting-user-input-with-scanner) – Eclipse Mar 12 '17 at 16:21

2 Answers2

1

You have to use new Scanner().nextLine() or just new Scanner().next() because there is no nextString() method in the Scanner;

Mouad EL Fakir
  • 3,609
  • 2
  • 23
  • 37
0

You should call next() method instead of nextString().

alayor
  • 4,537
  • 6
  • 27
  • 47