由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - [合集] 问一下这个cast在java里是怎么work的
相关主题
[合集] 谁能解释一下这里的protected specifier请教 class cast problem
说说clone咋违反了类继承的原则来的?请教一个动态cast的问题
copy constructor都什么时候be called啊如何造Array of Generic Type
immutable listIs there a way to pass by value in Java?
传递一个object reference,如何防止更改object?git clones only one branch?
Java复制object[转载] Re: java thread problem
Java里面有没有可能写个带generic parameter的class对built-in type也适用?an Array question
return type, map or objectHow would clear a BufferedImage?
相关话题的讨论汇总
话题: derived话题: cast话题: aug话题: fri话题: java
进入Java版参与讨论
1 (共1页)
I*******e
发帖数: 1879
1
☆─────────────────────────────────────☆
bruklyn (我爱布鲁克林) 于 (Fri Aug 10 03:13:39 2007) 提到:
public Derived Clone()
{
Derived d = (Derived) super.clone();
... set other fields in d
return d;
}
这里我理解没错的话super.clone()应该返回一个Base class type的object
怎么可能cast成derived class type,而且还能set field呢?
有没有高人能解释一下?
谢谢!
☆─────────────────────────────────────☆
magicfat (魔法胖子) 于 (Fri Aug 10 12:16:54 2007) 提到:
Are you sure it works for you? I got ClassCastException.
I can't see how it
1 (共1页)
进入Java版参与讨论
相关主题
How would clear a BufferedImage?传递一个object reference,如何防止更改object?
Question on JSP ELJava复制object
[合集] Web Service Java 客户端的问题Java里面有没有可能写个带generic parameter的class对built-in type也适用?
[合集] How to check whether a file is locked?return type, map or object
[合集] 谁能解释一下这里的protected specifier请教 class cast problem
说说clone咋违反了类继承的原则来的?请教一个动态cast的问题
copy constructor都什么时候be called啊如何造Array of Generic Type
immutable listIs there a way to pass by value in Java?
相关话题的讨论汇总
话题: derived话题: cast话题: aug话题: fri话题: java