Elegant solution to find a pair of Strings in a List
iA and iB can only take the values 0 and 1, so that

if ((1 == iA || 1 == iB) &amp;&amp; (1 != iA || 1 != iB)) { ... }


can be simplified to

if (iA != iB) { ... }


Boolean variables would be more appropriate for this purpose, and the variable names can be improved, e.g.

boolean containsA = false;
boolean containsB = false;