(1)new list int[10],(2) new list int[6]把(2)插入到(1)中,并返回最大数.请教值怎么做的啊,谢谢

解决方案 »

  1.   

    什么语法?就是把定义的new list int[10]插到new list int[6]里啊,返回其中最大的数啊
      

  2.   

    楼主是指两个int数组合并,然后求最大值把。用系统方法就是这样:
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    int[] a = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
    int[] b = new int[] { 10, 11, 12, 13, 14, 15 };
    // 开始解题
    int[] c = new int[a.length + b.length];
    //从a拷贝元素到c,a的第0个元素开始,对应从c的第0个元素开始覆盖,拷贝a.length个元素
    System.arraycopy(a, 0, c, 0, a.length);
    System.arraycopy(b, 0, c, a.length, b.length);
    //从小到大排序,c[0]最小。
    java.util.Arrays.sort(c);
    //输出最后一个数,就是最大的。
    System.out.println(c[c.length - 1]);
    }
      

  3.   

    当然如果楼主需要练基本功,这里是不用系统简便方法完成的代码。public class T2 { /**
     * @param args
     */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    int[] a = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
    int[] b = new int[] { 10, 11, 12, 13, 14, 15 };
    // 开始解题
    int[] c = new int[a.length + b.length];
    //a放入c中
    for (int i=0;i<a.length;i++){
    c[i]=a[i];
    }
    //b放入c中
    for(int i=a.length;i<c.length;i++){
    c[i]=b[i-a.length];
    }
    //把c打印出来看看
    for (int i=0;i<c.length;i++){
    System.out.print(c[i]+" ");
    }
    //冒泡排序,排成升序
    bubbleOrder(c);
    System.out.println(c[0]);

    } //升序冒泡方法
    public static int[] bubbleOrder(int[] array)   
        {   
    int tmp=0;
            for(int i=0;i<array.length;i++)   
            {   
                for (int j=array.length -1 ;j>i;j--)   
                {  
                        if (array[i] < array[j]){   
                         tmp=array[i];
                         array[i]=array[j];
                         array[j]=tmp;}
                }   
            }   
            return array;   
        }   
    }
      

  4.   

    list是什么?
    是List?
    List是接口...不是类~!
    再说了,就算是类,也应该是List<type>这样用...