title: What is the best way to remove repeated elements from a array?
body: <p>I accept a mobile numbers array, and I need to remove repeated numbers in the array. The way I choose is converting the array to a hashset, then convert it back to an array. Is there any better way?</p>
  
  <p>My code is below:</p>
  
  <pre><code>public static void main (String[] args) {
  
      String[] mobiles = new String[]{"1", "2", "3", "1", "1"};
  
      Set&lt;String&gt; data = new HashSet&lt;&gt;(Arrays.asList(mobiles));
      String[] result = data.toArray(new String[0]);
  
      for (String s : result) {
          System.out.println(s);
      }
  }
  </code></pre>