title: how to get substring items with in arraylist in java
body: <p>I have arraylist of strings, I need to find the substrings among the items in same arraylist?</p>
  
  <p>For example:</p>
  
  <pre><code>ArrayList&lt;String&gt; ar = new ArrayList();
  ar.add("UserId");  //adding item to arraylist
  ar.add("Directory");
  ar.add("Username");
  ar.add("PhoneNumber");
  </code></pre>
  
  <p>Here I want to find substring of items, basically I need output as UserId and Username from the list items. how can I do it can someone help me out.</p>