One typo: change while(record=false)
to while(record==false)
.
On top of that, your while
loop that runs while record == false
isn't running. This is because listOfTosses.get(0)
and listOfTosses.get(1)
are both set to 0.
When you do listOfTosses.add((int) Math.random()*2);
, it's actually equivalent to listOfTosses.add(((int) Math.random()) * 2);
. Since Math.random() < 1
, that gets turned into a 0. Do listOfTosses.add((int) (Math.random()*2));
instead.
Alternatively, instead of dealing with converting floats, consider the java.util.Random class. The nextInt(int n)
function looks like what you need.