I need to store different objects in the ArrayList. Objects are similar in nature but different and have different methods.
Circle c = new Circle(); Cube s =
List list = new ArrayList<>(); list.add(new ArrayList<>()); list.add(Integer.valueOf("24")); list.add(Long.valueOf("25")); list.add("STRING"); list.add(new Object()); System.out.println(Arrays.toString(list.toArray())); //Console print: " [[], 24, 25, STRING, java.lang.Object@4554617c] "
You may store any object type.