public static int take1(){
Scanner in = new Scanner(System.in);
while(true){
try{
System.out.print("\nHow many coloms you want = ");
return in.nextInt();
}
catch(Exception e ){
System.out.println("Sorry,Please enter only no.");
in.next();
}
}
}
how to close the scanner object , if i close this object using finally or try with resources it also closes System.in , and i cant read from stream more than once. what is the best method to do this?