No enclosing instance of type exp.invalidAgeException is accessible. Must qualify the allocation with an enclosing instance of type exp.invalidAgeException (e.g. x.new A() where x is an instance of exp.invalidAgeException).
public invalidAgeException (String massage){ super(massage); }
class AgeValidator {
void checkage(int age) {
try { if(age150) {
throw new invalidAgeException("age is not vaild"); } else { System.out.println("vaild age"); } } catch(Exception e){ System.out.println(e); } } }
public static void main(String[] args) {
Scanner scan = new Scanner(System.in); int age = scan.nextInt();
AgeValidator a1 = new AgeValidator(); a1.checkage(age);
} } } [/code] сообщение об ошибке [code]No enclosing instance of type exp.invalidAgeException is accessible. Must qualify the allocation with an enclosing instance of type exp.invalidAgeException (e.g. x.new A() where x is an instance of exp.invalidAgeException). [/code] но я не знаю, почему это появляется?