+ 6
Caution while taking input using Scanner in java
Scanner sc=new Scanner (System.in); int a =sc.nextInt(); String s=sc.nextLine(); This code will skip sc.nextLine ,and ends only taking an integer as input, as it(.nextLine()) will consume the new line character (Enter) given by user. You can read in detail , why is it so:- https://stackoverflow.com/q/13102045/9190688
2 Answers
+ 15
thanks for the information
//while making some codes , users encounter some errors due to this
//I have seen posts on it
+ 2
@ gaurav , its my pleasure