Updated comments

This commit is contained in:
Niket Agrawal 2023-09-19 23:45:25 +05:30
parent 50515d3070
commit 0f425a4573
1 changed files with 4 additions and 2 deletions

View File

@ -11,22 +11,24 @@ import java.util.function.Predicate;
public class AlternativeMultipeTypeList {
public static void main(String[] args) {
// List of Numbers
// List of Parent Class
ArrayList<Number> myList = new ArrayList<>();
myList.add(1.2);
myList.add(2);
myList.add(-3.5);
// List of Map
// List of Interface type
ArrayList<Map> diffMapList = new ArrayList<>();
diffMapList.add(new HashMap<>());
diffMapList.add(new TreeMap<>());
diffMapList.add(new LinkedHashMap<>());
// List of Custom Object
ArrayList<CustomObject> objList = new ArrayList<>();
objList.add(new CustomObject("obj1", 1));
objList.add(new CustomObject("obj2", 2));
// List via Functional Interface
List<Object> dataList = new ArrayList<>();
Predicate<Object> myPricate = inputData -> (inputData instanceof String || inputData instanceof Integer);