title: How to check whether String already exist in Arraylist?
body: <p>I have an app in which contain ArrayList of some String let suppose a,b,c,d and i have a String called pack. What i have to do is that i have to check whether pack is already exist in arraylist or not if not exist then i have to add it in arraylist. How do i do that</p>
  
  <p>code:-</p>
  
  <pre><code>ArrayList&lt;CBlackList&gt; appsListDataSet;
   public void setAppsDetails(String pack) {
      if (appsListDataSet != null &amp;&amp; appsListDataSet.size() &gt; 0) {
          for (int i = 0; i &lt; appsListDataSet.size(); i++) {
              CAppsModel appsModel = appsListDataSet.get(i);
              if (pack.equalsIgnoreCase(appsModel.getPackageName())){
                  //Not to know what to do here.
              }
          }
      } 
  }
  </code></pre>