title: Scanner Input Array sorting
body: <p>I am new to java. I would like to my code to take an array of max = 100 integers from a user then it should determine if there are any duplicate integers. It should then print NO if there are duplicates and YES if all integers are unique. It should sort the input from lowest to highest then print the index number and its corresponding integer after sorting. I can get the final sort output in order also. This is what I have so far.  Any ideas on how to do this better?</p>
  
  <pre><code>    public static void main(String args[]){            
          Scanner takeIn = new Scanner(System.in); 
          System.out.println("Enter the numbers separated by comma's");           
          String startRay = takeIn.next();           
          String[] allParts = startRay.split(",");
          int L = allParts.length;           
          int[] intAllParts = new int[allParts.length];                     
          Arrays.sort(allParts);                        
          for(int n=0; n&lt;L; n++){             
              intAllParts[n] = Integer.parseInt(allParts[n]);               
              System.out.println(" Index of " + n + " Value of " + allParts[n]);
          }            
          for(int n=1; n&lt;L; n++){
              intAllParts[n] = Integer.parseInt(allParts[n]);    
              if(intAllParts[n-1]==intAllParts[n]){
                     System.out.println(" First duplicate found at index " + (n));
                     System.out.println(" NO");
                     System.out.println(Arrays.toString(allParts) + " Array Values");
                     return;
              }                           
          }            
          Arrays.sort(allParts);    
          System.out.println(Arrays.toString(intAllParts) + " Array Values");
          System.out.println(" YES");           
          takeIn.close();
        }        
      }
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code>Enter the numbers separated by comma's
  
  9,6,4,3,22,12,7,8,44,33,21,19,26,48,55,61,15,14,2,61,27,76,79,84,93
  
   Index of 0 Value of 12
   Index of 1 Value of 14
   Index of 2 Value of 15
   Index of 3 Value of 19
   Index of 4 Value of 2
   Index of 5 Value of 21
   Index of 6 Value of 22
   Index of 7 Value of 26
   Index of 8 Value of 27
   Index of 9 Value of 3
   Index of 10 Value of 33
   Index of 11 Value of 4
   Index of 12 Value of 44
   Index of 13 Value of 48
   Index of 14 Value of 55
   Index of 15 Value of 6
   Index of 16 Value of 61
   Index of 17 Value of 61
   Index of 18 Value of 7
   Index of 19 Value of 76
   Index of 20 Value of 79
   Index of 21 Value of 8
   Index of 22 Value of 84
   Index of 23 Value of 9
   Index of 24 Value of 93
   First duplicate found at index 17
   NO
  [12, 14, 15, 19, 2, 21, 22, 26, 27, 3, 33, 4, 44, 48, 55, 6, 61, 61, 7, 76, 79, 8, 84, 9, 93] Array Values
  </code></pre>