Hello, at the time of writing one program, a question arose, which I did not like. When creating an array of squares knocks an error, what's the matter?
public class Main { public static void main(String[] args) { Scanner sc; int n; System.out.print("Введіть кількість квадратів: "); while (true) { sc = new Scanner(System.in); if (!sc.hasNextInt()) { System.out.print("Некоректний тип введеного числа! Повторіть спробу: "); } else { n = sc.nextInt(); sc.close(); return; } } // вс, что здесь пишу unreachable statement } }
retrunwithbreak? - pavel