title: Generating random numbers and sorting them out in Java
body: <p>My goal is to generate random number from 0 to 100 and add them into a linkedlist object and then sort the elements. </p>
  
  <p>This is my code so far. I'm running into problems when I want to display the sorted elements.</p>
  
  <p>The error I get:  Exception in thread "main" java.util.IllegalFormatConversionException: d != java.util.Arrays$ArrayList</p>
  
  <p>Can someone throw some light into this problem? Thank You</p>
  
  <pre><code>package com.LinkedLists;
  
  import java.util.Arrays;
  import java.util.Collection;
  import java.util.HashSet;
  import java.util.List;
  import java.util.LinkedList;
  import java.util.Random;
  import java.util.Set;
  
  public class InsertRandomElements {
  
      public static void main(String[] args) {
  
          // Create a random number object from 0 to 100.
          // Create an array object.
          Random r = new Random();
          int[] random = new int[100];
  
          // Insert random numbers into the array
          for (int i = 0; i &lt; random.length; i++) {
              random[i] = r.nextInt(100) + 1;
          }
  
          // Printing out the unsorted array
          for (int i = 0; i &lt; random.length; i++) {
              System.out.println(random[i]);
          }
  
          List&lt;int[]&gt; randomList = Arrays.asList(random);
  
          // Call the method in here.
          sortElements(randomList);
  
      }
  
      // Sort the elements
      private static void sortElements(Collection&lt;int[]&gt; values) {
  
          Set&lt;int[]&gt; set = new HashSet&lt;int[]&gt;(values);
  
          for (int[] is : set) {
              System.out.printf("Sorted Elements: %d ", values);
          }
  
          System.out.println();
      }
  
      // Calculate Sum of the elements
  
      // Calculate floating point average of the elements.
  
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/IoUOB.png" alt=""></p>