void (String[] args) { List<String> list = Arrays.asList("a", "b", "c", "d"); for (String o : list) { if (!o.isEmpty()) { System.out.println("Peek: " + o); System.out.println("Peek2: " + o); String n = ""; System.out.println(o); if (o.equals("c")) continue; System.out.println(o + "!!!" + n); new Runnable() { String e = "x"; public void run() { System.out.println(e); for (int i = 0; i < 10; i++) { if (e.length() == i) return; } } }.run(); } } for (String s : list) { if ("b".equals(s)) { System.out.println("Found:"); System.out.println(s); break; } } Optional<String> found = Optional.empty(); for (String qq : list) { if ("b".equals(qq)) { found = Optional.of(qq); break; } } found.ifPresent(str -> { System.out.println("Found:"); if(str.isEmpty()) return; // return inside ifPresent is not supported System.out.println(str); }); StringBuilder res = new StringBuilder(); for (String str : list) { if (str != null) { str = "[" + str + "]"; res.append(str); } } System.out.println(res); long count = 0L; for (String n : list) { if (!"a".equals(n)) { for (int i = 0; i < 3; i++) { System.out.println("In flatmap idx: " + i); System.out.println("In flatmap: " + n); count++; } } } System.out.println(count); }