public class TEST {
public static void main(String[] args) {
Random r = new Random();
List<Integer> al = new ArrayList<>();
al.add(r.nextInt(9)+1);
al.add(r.nextInt(9)+1);
al.add(r.nextInt(9)+1);
al.add(r.nextInt(9)+1);
al.add(r.nextInt(9)+1);
List<Integer> newal=sortMethod(al);
for (Integer integer : newal) {
System.out.println(integer);
}
}
private static List<Integer> sortMethod(List<Integer> al) {
for (int i = al.size()-1;i>0; i--) {
for (int j =0 ; j < i; j++) {
if(al.get(j)>al.get(j+1))
Collections.swap(al, j, j+1);
}
}
return al;
}
}
|