JAVAでカスタムクラスオブジェクトを作成したいのですが、エラーが表示されます...このエラーが発生する理由がわかりません。以前にJAVAを学び始めたので助けてください...
class main {
class student {
public int rollno;
public String name;
public int marks;
public void accept() {
rollno = 1;
name = "Pawan Mall";
marks = 100;
}
public void display() {
System.out.println(rollno);
System.out.println(name);
System.out.println(marks);
}
}
public static void main(String argv[]) {
student s = new student();
s.accept();
s.display();
}
}
コードのコンパイル中に直面したエラーであるコンパイル時に発生していました:
C:\Program Files\Java\jdk1.7.0_03\bin\student.java:28: error: non-static variable this cannot be referenced from a static context
student s = new student();
^
1 error
Tool completed with exit code 1