关于java的一个问题,求解决``` Triangle tr=new Triangle(); Shape sh=tr;这里Triangle是Shape的子类,那sh和tr是引用同一个对象吗,还是分别引用同一个对象的不同拷贝?还有,他们的内存空间是不是相同的? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 class Parent { int i = 3; void test() { System.out.println("Parent test()"); }}class Child extends Parent { int i = 5; void test() { System.out.println("Child test()"); }}public class HackersterTest { public static void main(String[] args) { Child c = new Child(); System.out.println(c.i);// 输出5 c.test();// 输出Child test() Parent p = c; System.out.println(p.i);// 输入3 p.test();// 输出Child test() }}楼主看看这个例子 怎么一次设置所有JLabel前景色 请高手指教一个Java Swing的问题. 提取数字问题 请高手帮忙给我看看gui 如何在java中执行zip压缩命令 各位大哥帮帮忙,谁有用java做的类似于股票k线图的例子,万分感谢 对话框问题 请教deprecated methods的用法 急!为什么我对mysql4.04建立了外键,但是外键是没有名称的??? (JBuilder)为什么在Applet上放上AWT中的Choice时,在inspector的Events中看不到Choice的任何事件? 我的一小段程序,一运行就空指针错误,为什么 本人初学JAVA不久,希望大侠们能提供一些基础题。
int i = 3; void test() {
System.out.println("Parent test()");
}
}class Child extends Parent {
int i = 5; void test() {
System.out.println("Child test()");
}
}public class HackersterTest {
public static void main(String[] args) {
Child c = new Child();
System.out.println(c.i);// 输出5
c.test();// 输出Child test()
Parent p = c;
System.out.println(p.i);// 输入3
p.test();// 输出Child test()
}
}
楼主看看这个例子