diff --git a/core-java-modules/core-java-collections-array-list-2/src/main/java/com/baeldung/list/multiple/objecttypes/AlternativeMultipeTypeList.java b/core-java-modules/core-java-collections-array-list-2/src/main/java/com/baeldung/list/multiple/objecttypes/AlternativeMultipeTypeList.java index d80f4627d3..6dd44e0ffa 100644 --- a/core-java-modules/core-java-collections-array-list-2/src/main/java/com/baeldung/list/multiple/objecttypes/AlternativeMultipeTypeList.java +++ b/core-java-modules/core-java-collections-array-list-2/src/main/java/com/baeldung/list/multiple/objecttypes/AlternativeMultipeTypeList.java @@ -25,8 +25,8 @@ public class AlternativeMultipeTypeList { // List of Custom Object ArrayList objList = new ArrayList<>(); - objList.add(new CustomObject("obj1", 1)); - objList.add(new CustomObject("obj2", 2)); + objList.add(new CustomObject("String")); + objList.add(new CustomObject(2)); // List via Functional Interface List dataList = new ArrayList<>(); @@ -36,6 +36,9 @@ public class AlternativeMultipeTypeList { UserFunctionalInterface myInterface = (listObj, data) -> { if (myPricate.test(data)) listObj.add(data); + else + System.out.println("Skipping input as data not allowed for class: " + data.getClass() + .getSimpleName()); return listObj; }; diff --git a/core-java-modules/core-java-collections-array-list-2/src/main/java/com/baeldung/list/multiple/objecttypes/CustomObject.java b/core-java-modules/core-java-collections-array-list-2/src/main/java/com/baeldung/list/multiple/objecttypes/CustomObject.java index f4d4be989d..eec81523f4 100644 --- a/core-java-modules/core-java-collections-array-list-2/src/main/java/com/baeldung/list/multiple/objecttypes/CustomObject.java +++ b/core-java-modules/core-java-collections-array-list-2/src/main/java/com/baeldung/list/multiple/objecttypes/CustomObject.java @@ -8,8 +8,7 @@ public class CustomObject { this.classData = classData; } - CustomObject(String classData, Integer intData) { - this.classData = classData; + CustomObject(Integer intData) { this.intData = intData; }