Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: ulkir
Added: Apr 28, 2020 11:02 PM
Modified: Apr 28, 2020 11:17 PM
Views: 132
  1.     public static Integer[] performLottery(int numNumbers, int numbersToPick) {
  2.         var numbers = new ArrayList<Integer>();
  3.         for(var i = 0; i < numNumbers; i++) {
  4.             numbers.add(i+1);
  5.         }
  6.         Collections.shuffle(numbers);
  7.         return numbers.subList(0, numbersToPick).toArray(new Integer[numbersToPick]);
  8.     }