top of page

package alıştırmalar;

 

import java.util.*;

public class exercise11_7 {

 

public static void main(String[] args) {

// TODO Auto-generated method stub

 

ArrayList<Integer> listem=new ArrayList<>();

for(int i=0;i<5;i++){

listem.add((int)(1+Math.random()*50));

}

System.out.println("--my usual list--\n"+listem);

 

shuffle(listem);

}

public static void shuffle(ArrayList<Integer> list){

ArrayList<Integer> newlist=new ArrayList<>();

int i=0;

while(i<list.size()){

int k=(int)(Math.random()*list.size());

newlist.add(list.get(k));

list.remove(k);

 

}

System.out.println("--shuffled list--\n"+newlist);

}

 

}

 

bottom of page