帮我看看哪里错了,运行时会报错。
package test;
public class A
{
protected int r;
protected static int g;
protected void p1()
{
}
protected static void p2()
{
}
/*public static void main(String a[])
{
//p3();
System.out.println ("fff");
}*/
}package test;
public class B extends A
{
/*public static void main (String a[] )
{
B b = new B();
System.out.println (b.r);
System.out.println (g);
b.p1();
p2();
}*/
}
package test.test1;
import test.*;public class C extends A
{
/*static void p3()
{
C c = new C();
System.out.println (c.r);
System.out.println (g);
c.p1();
p2();
}*/
public static void main(String a[])
{
//p3();
System.out.println ("fff");
}
}
package test;
public class A
{
protected int r;
protected static int g;
protected void p1()
{
}
protected static void p2()
{
}
/*public static void main(String a[])
{
//p3();
System.out.println ("fff");
}*/
}package test;
public class B extends A
{
/*public static void main (String a[] )
{
B b = new B();
System.out.println (b.r);
System.out.println (g);
b.p1();
p2();
}*/
}
package test.test1;
import test.*;public class C extends A
{
/*static void p3()
{
C c = new C();
System.out.println (c.r);
System.out.println (g);
c.p1();
p2();
}*/
public static void main(String a[])
{
//p3();
System.out.println ("fff");
}
}
解决方案 »
- 请教一个java GUI的问题,十分感谢!
- JLIst中清空所有内容
- 一个jframe 中,有一个按钮,每点一下,窗口都会变大一点请问怎么做啊
- 时钟日历代码的几个疑问搞不懂
- enum在Eclipse中不变颜色
- 生产者消费者应用实例
- 一个QQ介面,但是这介面运行出来不是我想要的介面,大哥们,帮帮看下
- axis1.6.2把java文件放web根目录下无效
- 关于&与&&的问题???
- DB2用Select * from taba where name line 'a_' 无效 为啥?
- 关于一个简单的Jdk 1.6.0环境变量设置问题!
- 发现三版thinking in java的一个错误,各位看看是不是?????
父类protected的全局变量在不同的包中只能直接使用System.out.println (r);
Exception in thread "main" java.lang.NoSuchMethodError: main
protected修饰的方法和变量和没有任何修饰的方法变量区别就在他的子类中
protected修饰的方法和变量在不同包的子类中是可见的.而没有修饰符的方法,变量是不可见的;
A,B在test包中
C在test1包中,我把main函数写在C类中就报错