(1)new list int[10],(2) new list int[6]把(2)插入到(1)中,并返回最大数.请教值怎么做的啊,谢谢 (1)new list int[10],(2) new list int[6]把(2)插入到(1)中,并返回最大数.请教值怎么做的啊,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 什么语法?就是把定义的new list int[10]插到new list int[6]里啊,返回其中最大的数啊 楼主是指两个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]); } 当然如果楼主需要练基本功,这里是不用系统简便方法完成的代码。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; } } list是什么?是List?List是接口...不是类~!再说了,就算是类,也应该是List<type>这样用... 如何rmic 指令,生成_***_Stub 文件 新手跪求一个数列的超大数 如何读取大文件(100M+) 高手们帮帮忙啊!!感激不尽啊 关于空格的正则表达式 JET3.0在JDK1.4.2以上版本上安装不了,怎么办? 一个java程序是中文转成unicode问题,有些不明白,请指教 一个集合,怎么样才能把符合某一特征的数据取出来? 有人对applet有研究么? 轻松拿分(关于JDO的问题) 关于内部类编译的calss文件与外部类编译的calss文件时间不同,是否有影响? 删除一个组件
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]);
}
* @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;
}
}
是List?
List是接口...不是类~!
再说了,就算是类,也应该是List<type>这样用...