title: Java Collections by user input
body: <p>In java collections 
  I should get user input as integers and sort it in Ascending order.</p>
  
  <pre><code>import java.util.*;   
  import java.io.*;
  class ArrayToCollection{ 
  
   public static void main(String args[]) throws IOException{
  
        BufferedReader in = new BufferedReader
        (new InputStreamReader(System.in));
        System.out.println("How many elements you want to add to the array: ");
        int n = Integer.parseInt(in.readLine());
        int[] num = new int[n];
        for(int i = 0; i &lt; n; i++){
           num[i] = in.readLine();
        }
       TreeSet&lt;String&gt; setA =new TreeSet&lt;String&gt;();
       setA.add(num);
       System.out.println(setA.contains(num));
      }
  }
  </code></pre>