- 1

what we takes input for strings inSystem.in that we are taking integer input.syntax is a=nextInt(System.in).whats about strings

14th Jun 2017, 5:31 AM
Tanuj
Tanuj - avatar
5 Answers
+ 4
You can get user input char by char, by setup your scanner object, and then use the next() method: import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); sc.useDelimiter(""); int i = 10; while (i-->0) { System.out.println(sc.next()); } } } ... but remember that the keyboard stream is buffered by OS, and will be released only when user press the 'enter' ('return') key ^^ So, if your purpose is to listen for user key press, you need to handle it by another way ;P
14th Jun 2017, 8:49 AM
visph
visph - avatar
+ 2
next() or nextLine()
14th Jun 2017, 5:41 AM
Da' BO$
Da' BO$ - avatar
+ 1
I don't think so.There is no method for character.
14th Jun 2017, 8:13 AM
Da' BO$
Da' BO$ - avatar
0
this is for character
14th Jun 2017, 5:54 AM
Tanuj
Tanuj - avatar
- 1
THANKS
17th Jun 2017, 1:19 PM
Tanuj
Tanuj - avatar