Advertisement
TeRackSito

Copia de una lista

Nov 14th, 2023
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.38 KB | None | 0 0
  1. public class EjercicioArrays {
  2.     public static void main(String[] args) {
  3.         int[] arrayInts = {1, 2, 3, 4, 5};
  4.         int[] arrayInts2 = new int[arrayInts.length];
  5.  
  6.         for (int i = 0; i < arrayInts.length; i++) {
  7.             arrayInts2[i] = arrayInts[i];
  8.         }
  9.  
  10.         arrayInts[0] = -1;
  11.  
  12.         printArray(arrayInts);
  13.         printArray(arrayInts2);
  14.     }
  15.  
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement