Label

Thứ Năm, 28 tháng 10, 2010

cannot be referenced from a static context

public class ClassesandObjects{
public static void main(String[] args){
int x = 3;
passMethod(x);
System.out.println("After invoking passMethod, x = " + x);
}
public /*static*/ void passMethod(int p){
p = 10;
System.out.println("Invoke passMethod, x = " + p);
}
}


ClassesandObjects.java:4: non-static method passMethod(int) cannot be referenced
from a static context
passMethod(x);
^
1 error

Không có nhận xét nào:

Đăng nhận xét