日期:2014-05-20 浏览次数:20752 次
public class Jiohuanshuju { public static void main(String []args){ int[] oldArray={1,2,3,4,5,6,7,8,9,0,14,0,15,17,16,0}; int[] newArray={11,12,13}; int[] tempAry=new int[newArray.length]; for(int i=0;i<newArray.length;i++){ tempAry[i]=newArray[i]; } newArray=new int[oldArray.length]; for(int i=0;i<oldArray.length;i++){ //// int j=0; // if(oldArray[i]!=0){ // newArray[j]=oldArray[i]; // j++; // } newArray[i]=oldArray[i]; } // int a=tempAry.length; // System.out.print("newArray={"+"\t"); oldArray=new int[tempAry.length]; for(int i=0;i<tempAry.length;i++){ oldArray[i]=tempAry[i]; // System.out.print(newArray[i]+","+"\t"); } // System.out.print("}"); System.out.print("old array:"); for(int i:oldArray){ System.out.print(i+","); } System.out.println(); System.out.print("new array:"); for(int i:newArray){ System.out.print(i+","); } } }