Comment out 的地方,可以用那两行代码代替,Lamda
// for (String n : names) {
// System.out.println(n);
// }
// Predicate<String> containsE = new Predicate<String>() {
// @Override
// public boolean test(String s) {
// return s.contains("e");
// }
// };
// Predicate<String> containsE = s -> s.contains("e");
names.removeIf(s -> s.contains("e"));
names.forEach(System.out::println);
// for (String n : names) {
// System.out.println(n);
// }
Comment out 的地方,可以用最后一行代码代替,Lamda
if (m.getAction() == MotionEvent.ACTION_DOWN) {
Log.d("CS203", "You just tapped at (" + x + "," + y + ")!");
// List<Duck> doomed = new ArrayList<>();
// for (Duck d : flock) {
// if (d.contains(x,y)) {
// //flock.remove(d);
// //break;
// doomed.add(d);
// }
// }
// for (Duck d : doomed) {
// flock.remove(d);
// }
flock.removeIf(d -> d.contains(x,y));