+ 4

Hii there can I write Scanner scn = new Scanner(System. In) ;char ch=scn.nextChar();

I mean does scanner class support character input by its next method ()

18th Jan 2017, 2:56 PM
Suryanarayan Behera
Suryanarayan Behera - avatar
6 Answers
+ 2
bro.You can't use "nextChar()".for this case use "nextLine()"
18th Jan 2017, 6:33 PM
Nochains
Nochains - avatar
+ 1
What happens is you allocate a space(scn) for systems input and you had allocated some space(ch) in the same input space(scn) for character type(char). if it is defined in any method!
18th Jan 2017, 3:18 PM
suhail
suhail - avatar
0
But it shows compile time error. @suhail
18th Jan 2017, 3:20 PM
Suryanarayan Behera
Suryanarayan Behera - avatar
0
do import java.util.Scanner in your program
18th Jan 2017, 3:25 PM
Himanshu Dugar
0
brother I don't think there is a method nextChar() in scanners class .use next() instead or use a array[1] for your program to store a character. I am just a rookie
18th Jan 2017, 3:36 PM
suhail
suhail - avatar
0
did you do the import? (import java.util.Scanner;)
18th Jan 2017, 6:33 PM
Nochains
Nochains - avatar