posted 17 years ago
Statement is true. One can't access non static code from a static method directly by their simple names.
In the program, Instance of Test is created and hence accessing its methods(both static and non static.) would not create any problem.
But incase if you try to call the non-static method without creating an instance of Test, then a compile time error is generated.
public class Test{
public static void main(String arg[]){
amethod(); // gives compile time error.
}
public void amethod(){
}
}
[ June 02, 2006: Message edited by: pramila ch ]
[ June 02, 2006: Message edited by: pramila ch ]