class Car{
void get()
{
System.out.println("Inside Car");
MyClass.func(); // non-static can access static
}
}
public class MyClass {
public static void main(String[] args) {
func();
Car cr = new Car();
cr.get();
}
public static void func()
{
System.out.println("Hello");
//Car.get(); // static cannot access non-static
}
}
No comments:
Post a Comment