Ich habe eine Methode, die in einem String-Array nimmt und findet die Durchschnitte der alle paar Elemente abhängig von der Länge. Ich möchte, dass die Methode die ersten paar Elemente im Array je nach dem Wert von Offset zu löschen.
public static double[] getMovingAverage(String[] priceList, int length, int offset){
double[] newPriceList = convert(priceList);
int listLength = newPriceList.length;
int counter = 0;
double listsum;
double[] movingAverage = new double[listLength];
try{
for (int aa = 0; aa < listLength-1; aa++){
listsum = 0;
for (int bb = 0; bb < length; bb++){
counter = aa+bb;
listsum = listsum + newPriceList[counter];
}
movingAverage[aa] = listsum / length;
}
if (offset>0){
//remove first #offset# elements
}
}catch(Exception e){
System.out.println(e);
}
return movingAverage;
}
*Anmerkung: convert(); wandelt String[] in double[] um