1.class StaticMethods{
2.static void one(){
3.two();
4.StaticMethods.two();
5.three();
6.StaticMethods.four();
7.}
8.static void two(){}
9.void three(){
10.one();
11.StaticMethods.two();
12.four();
13.StaticMethods.four()
14}
15void four(){}
16.}
which three lines are illegal?
答案是 5 行 6行 13行
求解答,谢谢~~
------解决思路----------------------
我是闲人我来,哈哈
class StaticMethods {
static void one() {
two();//省略了类名StaticMethods
StaticMethods.two();//静态方法one中调用 静态方法two,合法
three();//不合法,静态方法one中不能调用非静态方法three
StaticMethods.four();//不合法,静态方法one中不能调用非静态方法three,而且four要通过对象调用
}
static void two() {}
void three() {
one();
StaticMethods.two();
four();
StaticMethods.four();//不合法,four方法是非静态的,要通过对象 调用
}
void four() {
}
}