Generating an integer and use it as index for string array
<p>I recently started with android programming, with just basic knowledge in java.
I'm having trouble with my code,What I'm aiming is to display a randomly chosen text that's already programmed in my array after the button is clicked (onclick event).</p>

<pre><code>public void magicbegins() //
{
    int min = 0;
    int max = 3;
    Random r = new Random();
    int rand = r.nextInt(max - min + 1) + min;
    //generating random number from 0 to 3 to use as index in later event
    String[] magictext = {"yes", "no", "maybe"};

    TextView text = (TextView) findViewById(R.id.textView1);
    //using the generated number as index for programmed string array
    text.setText(magictext[rand]);
}
</code></pre>

<p>If any case this codes is not recommendable to use, will anyone provide a sample script that would do similar from what I aim at very least?</p>
