Affichage des articles dont le libellé est [Verständnisproblem] Array wird trotz void rückgabe verändert.. Afficher tous les articles
Affichage des articles dont le libellé est [Verständnisproblem] Array wird trotz void rückgabe verändert.. Afficher tous les articles

mercredi 30 novembre 2016

[Verständnisproblem] Array wird trotz void rückgabe verändert.

mercredi 30 novembre 2016 0
Hey Leute,
Ich habe eine Frage bezüglich folgenden Codes:

public class Main {
public static void main(String[] args){
int[] gramm = {1,1,1,1};
Berechnung test = new Berechnung();

test.grammVeränderung(gramm);

System.out.println(gramm[0]);
}
}

public class Berechnung {
public void grammVeränderung(int[] gramm){

for(int i = 0; i<4; i++){
gramm = 2;
}

}
}

Ergebnis: 2

Wieso lässt sich das Array gramm...


[Verständnisproblem] Array wird trotz void rückgabe verändert.

[Verständnisproblem] Array wird trotz void rückgabe verändert.
 
◄Design by Pocket►