Hallo,
ich bin neu hier und wollte Ihre Hilfe in Anspruch nehmen. Brauche ein Tipp wie ich aus einem 2d double Array eine Spalte an die Variable in andere Methode übergeben kann.
Array kann z.B. so aussehen:
(x y z)
12 14 15
13 16 18
14 18 21
Und ich will einer Variable A die Werte von y zuweisen (A= matrix[1].
Oder muss ich statt Variable A ein Array A[] einsetzen?!
Ich weiß, dass A= Test.Berechnen(matrix[1]); nicht geht, aber wie kann ich es korrekt schreiben?!
ich bin neu hier und wollte Ihre Hilfe in Anspruch nehmen. Brauche ein Tipp wie ich aus einem 2d double Array eine Spalte an die Variable in andere Methode übergeben kann.
Array kann z.B. so aussehen:
(x y z)
12 14 15
13 16 18
14 18 21
Und ich will einer Variable A die Werte von y zuweisen (A= matrix[1].
Oder muss ich statt Variable A ein Array A[] einsetzen?!
Java:
public class Test {
public static void Berechnen(){
double matrix[][] = new double[3][3];
matrix[0][0] = 12;
matrix[0][1] = 14;
matrix[0][2] = 15;
matrix[1][0] = 13;
matrix[1][1] = 16;
matrix[1][2] = 18;
matrix[2][0] = 14;
matrix[2][1] = 18;
matrix[2][2] = 21;
}
public static void main(String[] args) {
for(int i=0; i<2;i++){
A= Test.Berechnen(matrix[i][1]);
}
double G=A*2-3;
}
}
Zuletzt bearbeitet: