java吧 关注:1,276,721贴子:12,792,931
  • 3回复贴,共1

菜鸟求帮助啊,这个问题太深啦,自己解决不了

只看楼主收藏回复

照着书打的为什么图片上传不了
public class Test1
{
public static void main(String[] args)
{
Test1 rs = new Test1();
System.out.println("<1>运用排除法生成不重复的随机序列");
printArray(rs.exclusionSort(6));
}
public Integer[] exclusionSort(int len)
{
Random random = new Random();
ArrayList result = new ArrayList();
while (result.size() < len)
{
Integer randnum = new Integer(random.nextInt(15));
if (!result.contains(randnum))// 判断此List有没有包含此元素有返回true
result.add(random);
}
;
return (Integer[]) result.toArray(new Integer[0]);// 将列表转换为数组返回
}
public static void printArray(Integer[] data)
{
if (data != null)
{
for (int i = 0; i < data.length; i++)
System.out.println(data[i] + "\t");
}
System.out.println();
}
}


1楼2014-04-29 11:09回复
    为什么没语法错误运行会显示什么数组类型不匹配


    2楼2014-04-29 11:10
    回复
      2025-09-04 04:07:15
      广告
      不感兴趣
      开通SVIP免广告
      在线等啊~~~


      3楼2014-04-29 11:11
      回复
        没人吗


        4楼2014-04-29 11:21
        回复