Java random class program
<p>In the below program i have 19 elements in the array id. Since I used random class it randomly retrieves the id from the array with duplicates. I need to avoid duplicate values and print all the values in the array randomly.</p>

<pre><code>import java.util.Random;
public class random {
public static void main(String[] args) {
    int[] id={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
    Random rand=new Random();
    for(int i=0;i&lt;20;i++)
    {
             int alength=id.length;
    //System.out.println("Length="+alength);
    int index1=rand.nextInt(alength);
    int team=id[index1];
    System.out.println("Team="+team);
    }}}
</code></pre>
