void (List<List<String>> list) { boolean b = true; OUTER: for (List<String> x : list) { if (x != null) { for (String s : x) { if (!s.startsWith("a")) { b = false; break OUTER; } } } } if(b) { System.out.println("ok"); } }