java中静态方法中不能调用非静态方法

如题所述

第1个回答  2019-03-30
静态static方法中不能调用非静态non-static方法是值得是不能直接调用non-static方法
public
class
Test01
{
public
static
void
main(String[]
args)
{
hello();
}
public
void
hello()
{
}
}
是指的这种
在静态的main方法中,直接调用了本类的非静态方法hello(),这种是不允许的
相似回答