public class forEachTest {
public static ConcurrentHashMap<String, String> cr = new ConcurrentHashMap<String, String>();
public static String logInfo = "";
public static void main(String[] args) {
cr.put("a", "name");
cr.put("b", "age");
cr.put("c", "time");
cr.forEach((k, v) -> addLog(k));
System.out.println(logInfo);
}
public static void addLog(String str) {
logInfo = logInfo + str + "||";
}
}
public static ConcurrentHashMap<String, String> cr = new ConcurrentHashMap<String, String>();
public static String logInfo = "";
public static void main(String[] args) {
cr.put("a", "name");
cr.put("b", "age");
cr.put("c", "time");
cr.forEach((k, v) -> addLog(k));
System.out.println(logInfo);
}
public static void addLog(String str) {
logInfo = logInfo + str + "||";
}
}