프로그래밍/Java

[Java] No enclosing instance of type Main1 is accessible. Must qualify the allocation with an enclosing instance of type Main1 (e.g. x.new A() where x is an instance of Main1 ).

창수씨 2022. 11. 3. 21:57
반응형

Main이 있는 곳에 class를 추가했더니 이렇게 나왔는데 그냥 추가한 클래스 앞에 static을 붙여주면 해결된다.

static public class Account {
		private int account;
		private double balance;
...
}
public static class Account {
		private int account;
		private double balance;
...
}

이렇게 하면 된다.

반응형