Created
April 5, 2020 04:14
-
-
Save parzibyte/ac1b066a3fe7c4289320e62a4d615200 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
En Java, ¿se pasa por referencia o por valor? | |
____ _____ _ _ _ | |
| _ \ | __ \ (_) | | | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___ | |
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \ | |
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/ | |
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___| | |
__/ | __/ | | |
|___/ |___/ | |
Blog: https://parzibyte.me/blog | |
Ayuda: https://parzibyte.me/blog/contrataciones-ayuda/ | |
Contacto: https://parzibyte.me/blog/contacto/ | |
Copyright (c) 2020 Luis Cabrera Benito | |
Licenciado bajo la licencia MIT | |
El texto de arriba debe ser incluido en cualquier redistribución | |
*/ | |
import java.util.Arrays; | |
class Main{ | |
public static void main(String[] args){ | |
int numeros[] = {1, 2, 3}; | |
System.out.println("Antes de intentar cambiar el elemento del arreglo: "); | |
System.out.println(Arrays.toString(numeros)); | |
// Intentamos cambiar | |
intentarCambiarArreglo(numeros); | |
System.out.println("Despues de intentar cambiar el elemento del arreglo: "); | |
System.out.println(Arrays.toString(numeros)); | |
} | |
/* | |
Demostración de que los elementos del arreglo pueden cambiarse | |
*/ | |
public static void intentarCambiarArreglo(int[] arreglo){ | |
// Intentamos cambiar el primer elemento... | |
arreglo[0] = 666; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment