Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created March 4, 2021 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/d5089087f8cf82232408e7fe502c374b to your computer and use it in GitHub Desktop.
Save parzibyte/d5089087f8cf82232408e7fe502c374b to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
int[] numeros = { 10, 50, 12, 55 };
// Alojar espacio
int[] copiaDeNumeros = new int[numeros.length];
// Clonar
System.arraycopy(numeros, 0, copiaDeNumeros, 0, numeros.length);
// Imprimir para demostrar que tienen los mismos elementos
for (int i = 0; i < numeros.length; i++) {
System.out.printf("Dentro de arreglo 1 en la posición %d existe %d y en el arreglo 2 existe %d\n", i,
numeros[i], copiaDeNumeros[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment