ArrayList<String> al=new ArrayList<String>();
al.add("123");
ArrayList<String> bl;
bl=al.clone(); --这句报Type safety: Unchecked cast from Object to ArrayList<String>
警告改为bl=(ArrayList<String>)al.clone();附带问一个问题,java中如何检测内存泄露。在MyEclipse中有没有什么好的内存泄露检测的方法。
al.add("123");
ArrayList<String> bl;
bl=al.clone(); --这句报Type safety: Unchecked cast from Object to ArrayList<String>
警告改为bl=(ArrayList<String>)al.clone();附带问一个问题,java中如何检测内存泄露。在MyEclipse中有没有什么好的内存泄露检测的方法。
解决方案 »
- 在线等!重命名文件夹的问题
- 能不能详细讲解一下Java中链表的用法?
- 编写一个菜单驱动的管理程序
- java怎样提取图片元素
- java.lang.IllegalArgumentException: SMC发送过来的消息错误
- 假如你的java項目經理是
- JAVA如何在linux上启动后台??
- 请问在select的where条件中,where dgitem ='3011' or dgitem ='3012' or dgitem ='3021'的效率高还是where dgitem in('3011' ,'3012', '
- 请教,弱弱问题2,关于BufferedImage
- 使用springdata jpa 怎样实现多表连接查询 注意是多个表查询不是多个条件!
- 关于一个程序的实现问题~~~
- [求助]谁能给个后台线程的例子?
windowbuilderpro实在做得太好了,他们的CodePro Profiler™也相当不错,值得一试。
留着不好吗?
必要的话恐怕需要写一个Ybhzf类继承ArrayList,然后重写clone()方法...
public Object clone() {
try {
ArrayList<E> v = (ArrayList<E>) super.clone();
v.elementData = Arrays.copyOf(elementData, size);
v.modCount = 0;
return v;
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}可以看到它已经重写了clone方法,没有特殊需要的话,我想你不用重写吧,不过不明白它为什么以Object类型返回
我想你只能强制转换吧。