how to clear input buffer in java
问题 For avoiding any unwanted character which has been entered in console like \n we use nextInt() or nextLine() etc. But in these cases actually the control is going a step ahead leaving the unwanted string or something like this. But I want to delete or flush out the memory of buffer in which other unwanted data is taken by the system. For example --> Scanner scan=new Scanner(System.in); scan.nextInt(); scan.nextline();//this statement will be skipped because the system is taking \n as a line