There is a code with two cycles. The first enumerates the first element of the cycle. The second cycle enumerates 2 elements of the cycle and compares between them.
for (String s1 : list) { int count = 0; for (String s2 : list) { if (s1.equals (s2)) { count++; result.put (s1, count); } } I would like to do this in one fori loop so that the index element 0 is compared with the index of element 1, how can this be done without falling out of the cycle?
contains( )method that both HashSet ( HashSet: contains () ) and ArrayList ( ArrayList: contains () ) has - Alex Krass