数组怎么强制类型转换

谁学逆向工程 2016-08-19 10:11:30
import java.util.*;
public class demo
{
public static void main(String[]args)
{
ArrayList<xx> liaoguodi = new ArrayList<xx>();
xx x1 = new xx();
xx x2 = new xx();
liaoguodi.add(x1);
liaoguodi.add(x2);
liaoguodi.remove(0);

xx u9 = new xx();
liaoguodi.set(0,u9);

xx [] arr = (xx[])liaoguodi.toArray();
System.out.println( arr.length) ;
}

}

class xx//任意类型
{}


...全文
713 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Vencc__ 2016-08-19
  • 打赏
  • 举报
回复
ArrayList<XX> arrayList=new ArrayList(); arrayList.add(new XX()); arrayList.add(new XX()); XX[] xxs=new XX[arrayList.size()]; arrayList.toArray(xxs); System.out.println(xxs.length);

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧