本帖最后由 changchunhaha 于 2014-4-3 14:40 编辑
- class A
- {
- void fun1()
- {
- System.out.println(fun2());
- }
- int fun2()
- {
- return 123;
- }
- }
- public class B extends A //用命令行时可以编译运行,但是在用Eclipse写代码时却会有这么“The public type B must be defined in its own file"提示?求解?
- {
- int fun2()
- {
- return 456;
- }
- public static void main(String args[])
- {
- B b = new B();
- b.fun1();
- A a = b;
- a.fun1();
- }
- }
复制代码
|
|