Java tutorial
//package com.java2s; import java.util.ArrayList; public class Main { /** * gets the first value on the first AL that is equal to another in the second * * @param alFirst * @param alSecond * @return the string value equal between the two AL, or null if such value doesn't exist */ public static String getFirstSameValue(ArrayList<String> alFirst, ArrayList<String> alSecond) { // cycles of the first AL for (int j = 0; j < alFirst.size(); j++) { // gets the j-th value String strValue = alFirst.get(j); // cycles of the second AL for (int i = 0; i < alSecond.size(); i++) { // if the two values are equal, return the value if (strValue.equals(alSecond.get(i))) return strValue; } } // hasn't found nothing, so returns null return null; } }