对象转型的例子
来源:互联网 发布:php微信源码下载 编辑:程序博客网 时间:2024/06/05 04:02
对象转型的例子,有需要的可以看看
public class Test3 {public static void main(String[] args) {Animal a=new Animal("name");Dog d=new Dog("wangwang","black");a=new Dog("bigyellow","yellow");System.out.println(a.name);System.out.println(a instanceof Animal);System.out.println(a instanceof Dog);a=new Cat("mm","green");if(a instanceof Cat){Cat d1=(Cat)a;System.out.println(d1.eyesColor);}}}class Animal{public String name;Animal(String name){this.name=name;}}class Cat extends Animal{public String eyesColor;Cat(String n,String c){super(n);eyesColor=c;}}class Dog extends Animal{public String furColor;Dog(String n,String c){super(n);furColor=c;}}
0 0
- 对象转型的例子
- 对象转型的小例子
- 对象的转型
- 关于对象的转型
- 对象的转型
- 对象的转型
- 7、对象的转型
- 对象的转型
- 对象的转型_21
- Java4Android-对象的转型
- 对象的转型
- #java#对象的转型
- java21对象的转型
- 对象的向上转型和向下转型
- 对象的转型(向上向下转型)
- 对象的上转型对象
- 对象的上转型对象
- 对象的上转型对象
- 一直忍让。。脾气激情岂不是受委屈了
- httputils及xlistview刷新
- oracle 里面declare怎么用啊?
- 随意更改网页内容
- 题目:js类型判断
- 对象转型的例子
- Linux : ext3_free_blocks: Freeing blocks not in datazone
- 关于<context:property-placeholder>
- (原) ORA-01704:文字字符串过长
- 鸟哥Java学习之基本数据类型包装类--常用对象API
- HDU1115 Lifting the Stone
- ORA-01704: 文字字符串过长
- 【刷题之路】寻找奇数次出现的数
- 每日一linux命令(7)-------mv