Linux教程網
JAVA數組的遍歷,使用了新的遍歷方法foreach
數組的遍歷,使用了新的遍歷方法foreach
- import java.util.Arrays;
- /**
- * 數組的遍歷,使用了新的遍歷方法foreach
- * @author HAN
- *
- */
- public class ArrayDispApps {
-
- public static void main(String[] args) {
- int arr1[]=new int[]{2,3,4,6,7};
- int arr2[]=Arrays.copyOf(arr1, arr1.length);
-
- for(int x:arr2){ // foreach application
- System.out.print(x+" ");
- }
-
- arr1[0]=55;
- System.out.println();
- for(int x:arr1){
- System.out.print(x+" ");
- }
-
- System.out.println();
- for(int x:arr2){
- System.out.print(x+" ");
- }
-
- }
-
- }
Copyright ©
Linux教程網 All Rights Reserved