L
LucasBarrios
Gast
Hi, ich bin noch Anfänger in Java. Ich möchte ein Programm schreiben, dass komplexe Rechenoperationen ausführt.
Nun möchte ich aus einer anderen Klasse aus einer nicht-statischen Methode die Methode calculateRofRLC aufrufen und den zurückgegebenen Array speichern:
Nur leider unterstrichelt er mir die Zeile mit:
Cannot make a static reference to the non-static method calculateRofRLC() from the type RLC
Ich hab im Internet leider keine Lösung für mein Problem gefunden, kann mir jemand helfen?
Java:
public class RLC {
private static final Complex RESISTOR = new Complex(10, 0);
private static final double INDUCTANCE = 0.01;
private static final double CAPACITY = 0.00000001;
private static double frequency[] = new double[10];
private static double radialFrequency[] = new double[10];
public static Complex[] calculateRofRLC() {
Complex[] voltageResistor = new Complex[10];
for (int index = 1; index <= 10; index++) {
frequency[index - 1] = (10000 + (index * 1000));
radialFrequency[index - 1] = (frequency[index - 1] * Math.PI * 2);
}
for (int index = 0; index < 10; index++) {
voltageResistor[index] = voltageOverResistor(radialFrequency[index]);
}
return voltageResistor;
}
public static Complex voltageOverResistor(double radialFrequency) {
Complex imaginary = new Complex(
0,
((radialFrequency * INDUCTANCE) - (1 / (radialFrequency * CAPACITY))));
Complex impedance = Complex.add(RESISTOR, imaginary);
Complex voltageOperating = new Complex(1, 0);
Complex current = Complex.div(voltageOperating, impedance);
Complex voltageResistor = Complex.mul(RESISTOR, current);
return voltageResistor;
}
}
Nun möchte ich aus einer anderen Klasse aus einer nicht-statischen Methode die Methode calculateRofRLC aufrufen und den zurückgegebenen Array speichern:
Java:
Complex[] test = RLC.calculateRofRLC();
Nur leider unterstrichelt er mir die Zeile mit:
Cannot make a static reference to the non-static method calculateRofRLC() from the type RLC
Ich hab im Internet leider keine Lösung für mein Problem gefunden, kann mir jemand helfen?