Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:Good Example. Plz, give me one point [Re:floater]
jam





发贴: 79
积分: 30
于 2003-04-11 09:35 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
class A {
int i = 1;
int f() {
return i;
}
static char g() {
return 'A';
}
}

class B extends A {
int i = 2;
int f() {
return -1;
}
static char g() {
return 'B';
}
}

public class Test {
public static void main(String args[]) {
B b = new B();
System.out.println(b.i); // 2
System.out.println(b.f()); // -2
System.out.println(b.g()); // B
System.out.println(B.g()); // B

A a = (A) b;
System.out.println(a.i); // 1
// ****************
System.out.println(a.f()); // -2
// ****************
System.out.println(a.g()); // A
System.out.println(A.g()); // A
}
}

Sorry, I come from Taiwan, I can not post encoding by "GB2312" or "HZ"
The system will be using "Big5"

The exmaple is in "Java in a nutshell".
The chinese version is in "chapter 3" java object orient.
About subclass and inheritance, over write the method of super class.

I think it can be explain by "Polymorphism"




如何用JTable设置表头多行

话题树型展开
人气 标题 作者 字数 发贴时间
8045 Good Example. Plz, give me one point jam 907 2003-04-09 19:29
7233 Re:Good Example. Plz, give me one point why 30 2003-04-10 22:19
7102 Re:Good Example. Plz, give me one point floater 128 2003-04-11 00:43
7271 Re:Good Example. Plz, give me one point jam 920 2003-04-11 09:35
7213 Re:Good Example. Plz, give me one point jam 381 2003-04-14 15:09
7321 Re:Good Example. Plz, give me one point jam 373 2003-04-15 13:54
7047 Re:Good Example. Plz, give me one point floater 68 2003-04-11 14:20
7244 Re:Good Example. Plz, give me one point jam 678 2003-04-11 16:07
6843 Re:Good Example. Plz, give me one point jiangns3000 12 2003-04-11 15:02
6968 Re:Good Example. Plz, give me one point jiangns3000 259 2003-04-11 20:46
6835 Re:Good Example. Plz, give me one point jiangns3000 55 2003-04-11 20:50
6893 Re:Good Example. Plz, give me one point jiangns3000 131 2003-04-11 22:33
6912 Re:Good Example. Plz, give me one point jiangns3000 141 2003-04-11 23:10
6999 Re:Good Example. Plz, give me one point floater 49 2003-04-12 07:27
7283 Re:Good Example. Plz, give me one point jam 1699 2003-04-14 10:03
7156 Re:Good Example. Plz, give me one point jam 262 2003-04-14 10:12

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923