I need to put in a array
of double
the data of the quantity field that comes from the database. When doing this with the following code:
static List<Historico> listaComCincoUltimosMeses = new ArrayList<Historico>
();
static double[] arrayinvertidoComUltimosCincoMeses = new double[listaComCincoUltimosMeses.size()];
int k = 0;
for (Historico hist : listaComCincoUltimosMeses) {
System.out.println(hist.getMesesHistoricos() == null ? "Erro" :
hist.getMesesHistoricos());
System.out.println(hist.getQuantidade());
arrayinvertidoComUltimosCincoMeses[k] = hist.getQuantidade();
System.out.println(arrayinvertidoComUltimosCincoMeses.length);
System.out.println("Array"+ arrayinvertidoComUltimosCincoMeses[k]);
k++;
}
I get the following error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
Does anyone know why?
I want to put in an array of double because I get the array as input into a function.
public static double fatorAmortecimentoExponencial(double... d) {
...
}