I'm trying to write code that stores 50 randomly generated floating point numbers in an ArrayList. Use a regular for-loop to cycle through the values and remove any that are less than 0.5. Then use a for-each loop to print out the values that remain.
this is my code so far and I don't know where to go from here...
import java.util.ArrayList;
public class fiftyFloats {
public static void main (String [] args){
//create a reference for the array list
ArrayList <Float> vals;
//reserve space for it in memeory
vals = new ArrayList <Float> (50);
for (int i = 0; i<vals.size(); i++){
i = new Float
}
for (Integer atPos: vals){
System.out.println(vals.toString());
}
}
}
Aucun commentaire:
Enregistrer un commentaire