[java] how to cast after clone()?
所在版块:技术の宅 发贴时间:2006-04-06 02:18

用户信息
复制本帖HTML代码
高亮: 今天贴 X 昨天贴 X 前天贴 X 

Vector<A> a= new Vector<A>();
Vector<A> b= a.clone(); //1.
Vector<A> b=(Vector) a.clone();//2.
Vector<A> b=(Vector<A>) a. clone(); //3

i have tried all the three ways of casting, but all of them will produce either an error or a warning. Can anyone suggest how to do casting in this case? thanks a lot in advance!

.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!

少上网
 相关帖子 我要回复↙ ↗回到正文
[java] how to cast after clone()? 蚂蚁   (317 bytes , 874reads )
1.5的东东比1.4变了好多,搞的连java也不会写了^_^ 门中木   (0 bytes , 187reads )
try Vector<String> b = new Vector<String>(a); 绿竹幽径   (51 bytes , 388reads )
有一点点不一样 吴永铮   (134 bytes , 256reads )
能解释一下deep clone and shallow clone 么? icky   (0 bytes , 211reads )
Shallow clone 抽烟看球   (97 bytes , 213reads )
is it similar to copy pointer and copy objects in C? icky   (0 bytes , 230reads )
I didnt make my statement clear enuf 抽烟看球   (266 bytes , 213reads )
so shallow is just assign a reference , am I right 门中木   (0 bytes , 266reads )
copy object for container, copy referrence for contained object 抽烟看球   (0 bytes , 191reads )
我试了,第三个可以啊 吴永铮   (470 bytes , 293reads )
多谢!第三个是可以,不过 蚂蚁   (84 bytes , 251reads )
Leave it 抽烟看球   (212 bytes , 235reads )
总是觉得compile之后还有一行字,看起来实在是很不爽! 蚂蚁   (0 bytes , 237reads )
what is Vector<A> for? 逃课专家   (9 bytes , 241reads )
就是说这个vector里面放的都是A这个class的object 蚂蚁   (0 bytes , 290reads )