I want an array of objects from a class named 'Complejo'but there's something wrong i cannot detect. Are those arrays, 'temp' and 'tempo', properly created?
public class Complejo {
private double a;
private double b;
private int k=0;
public Complejo[] raices(int n) {
Complejo[] temp = new Complejo[n];
Complejo[] tempo = new Complejo[n];
for(k=0; k<n-1; k++) {
temp[k] = new Complejo(Math.pow(a,1/n),(b+k*2*Math.PI)/n);
tempo[k] = new Complejo(temp[k].getParteReal(),temp[k].getParteImaginaria());
}
return tempo;
public String toString() {
return "Resultado : " + a +" + " + b + " i ";
}
}
class menu {
public static void main(String args[]) {
int n,k;
Complejo[] c4;
c4 = c1.raices
;
for(k=0; k<n-1; k++)
System.out.println(c4[k].toString());
}
}
public class Complejo {
private double a;
private double b;
private int k=0;
public Complejo[] raices(int n) {
Complejo[] temp = new Complejo[n];
Complejo[] tempo = new Complejo[n];
for(k=0; k<n-1; k++) {
temp[k] = new Complejo(Math.pow(a,1/n),(b+k*2*Math.PI)/n);
tempo[k] = new Complejo(temp[k].getParteReal(),temp[k].getParteImaginaria());
}
return tempo;
public String toString() {
return "Resultado : " + a +" + " + b + " i ";
}
}
class menu {
public static void main(String args[]) {
int n,k;
Complejo[] c4;
c4 = c1.raices
for(k=0; k<n-1; k++)
System.out.println(c4[k].toString());
}
}