Sun Oct 21, 2012 12:28 pm
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
List<Float> floatList = new ArrayList<Float>();
for (float num = 0; num < 1; num+=0.05) {
floatList.add(num);
}
Iterator listIterator = floatList.iterator();
while (listIterator.hasNext()) // check if it has next
{
System.out.println(listIterator.next());
}
}
}
0.0
0.05
0.1
0.15
0.2
0.25
0.3
0.35000002
0.40000004
0.45000005
0.50000006
0.5500001
0.6000001
0.6500001
0.7000001
0.7500001
0.80000013
0.85000014
0.90000015
0.95000017
List<Float> floatList = new ArrayList<Float>();
for (float num = 0; num < 1; num+=0.05) {
floatList.add(new Random().nextFloat()*num);
}
Iterator listIterator = floatList.iterator();
while (listIterator.hasNext()) // check if it has next
{
System.out.println(listIterator.next());
}
Iterator listIterator = floatList.iterator();
for (;listIterator.hasNext();) // check if it has next
{
System.out.println(listIterator.next());
}
Iterator<Float> listIterator = floatList.iterator();
while (listIterator.hasNext()) // check if it has next
{
Float fnum= listIterator.next();
fnum+=0.1f;
System.out.println(fnum);
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.