package game1;
import java.util.Scanner;
public class toothpicks {
private int number;
public int HowMany()
{
do
{
System.out.print("Enter the No. of ToothPicks = ");
Scanner input =new Scanner(System.in);
number = input.nextInt();
if(number<4)
{
System.out.print("ToothPicks Should be greater than 3\n");
}
}while(number<4);
return number;
}
}
Where can I close the input
Scanner in my program? It giving me error if I close it in the end of the Program just before return statment says input can not be resolved
but if I close it in the loop then I cannot achieve what i'm trying to by using this HowMany
Method? What to do ? Any help would be appreciated