what is the correct method of inserting a char variable in java program? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

what is the correct method of inserting a char variable in java program?

3rd Jun 2017, 11:14 AM
Chaman Raghav
Chaman Raghav - avatar
2 Answers
+ 13
If you mean input, there is no nextChar() method in Scanner class. You may try the following way: Scanner sc = new Scanner(System.in); char a = sc.next().charAt(0);
3rd Jun 2017, 2:07 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 2
yes finally it works... thanku yassu😊😊
3rd Jun 2017, 6:16 PM
Chaman Raghav
Chaman Raghav - avatar