Arrays/Arraylists HW
here is my array/arraylists HW frq
Part A
public void cleanData(double lower, double upper) {
Iterator<Double> iterator = temperatures.iterator();
while (iterator.hasNext()) {
double temp = iterator.next();
if (temp < lower || temp > upper) {
iterator.remove();
}
}
}
Part B
public int longestHeatWave(double threshold) {
int maxLength = 0;
int currentLength = 0;
for (double temp : temperatures) {
if (temp > threshold) {
currentLength++;
maxLength = Math.max(maxLength, currentLength);
} else {
currentLength = 0;
}
}
return maxLength;
}