エラーの意味がわからない
入門の本の実践中(Java)でエラーが起こりましたが、エラーの内容の意味がイマイチ理解できません。
プロブラミング超初心者ですので、どうか丁寧な解説お願いします。
発生している問題・エラーメッセージ
No enclosing instance of type SampleClass is accessible. Must qualify the allocation with an enclosing instance of type SampleClass (e.g. x.new A() where x is an instance of SampleClass).
該当のソースコード
java
1public class SampleClass { 2 3 public class PrintCounter{ 4 5 public int count = 0; 6 7 public void print() { 8 count++; 9 System.out.println("Number of call" +count); 10 } 11 } 12 13 14 public static void main(String...args) { 15 PrintCounter printCounter = new PrintCounter(); 16 printCounter.print(); 17 printCounter.print(); 18 printCounter.print(); 19 20 } 21 22 23}
補足情報
new PrintCounter()でエラーが起こっています。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/10 03:08
2018/02/10 04:12
退会済みユーザー
2018/02/10 04:57 編集
2018/02/10 08:23