This site requires JavaScript, please enable it in your browser!
Greenfoot back
JasonZhu
JasonZhu wrote ...

2014/3/19

A weird problem

JasonZhu JasonZhu

2014/3/19

#
Either it's something that I fail to see or something's wrong. Can someone explain why the last element of the generation stays 0 with the current code?
    public void generateArray(int max)
    {
        for(int i=0;i<list.length-1;i++){//why is it that its missing a value when list.length-1?
            list[i] = (int)((Math.random()*max)+1);
        }
    }
Thanks guys.
JasonZhu JasonZhu

2014/3/19

#
Nevermind guys, I found out why.
You need to login to post a reply.