title: How to find a String in ArrayList and get index of that String?
body: <p>I have a <code>String</code> and i want to find in <code>ArrayList</code> with index or position i write code but when this is not working. <code>itemName</code> is one <code>String</code>. If condition is being <code>true</code> but it is not going to if block....</p>
  
  <pre><code>public int getIndex(String itemName)
  {
      for (int i = 0; i &lt; kvArrayList.size(); i++)
      {
          KeyValueType kv = kvArrayList.get(i);
          if (kv.getName().equalsIgnoreCase(itemName))
          {
              return i;
              //if condition is true but not coming here
          }
      }
      return -1;
  }
  </code></pre>
  
  <p>KeyValueType.class(Modal)</p>
  
  <pre><code>import java.io.Serializable;
  
  public class KeyValueType implements Serializable{
  private static final long serialVersionUID = 6121835779951930267L;
  String id;
  String name;
  
  public KeyValueType(String id, String name) {
      this.id = id;
      this.name = name;
  }
  
  @Override
  public String toString() {
      return name.toString();
  }
  
  public String getId() {
      return id;
  }
  
  public void setId(String id) {
      this.id = id;
  }
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  }
  </code></pre>