From 7afb1b2dc885fe3318468a615a7471000821faec Mon Sep 17 00:00:00 2001 From: Kirti Deo Date: Wed, 22 Aug 2018 20:17:33 +0530 Subject: [PATCH] BAEL-2024 : Fixed review comments by Darragh. --- .../baeldung/classcastexception/ClassCastException.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/classcastexception/ClassCastException.java b/core-java/src/main/java/com/baeldung/classcastexception/ClassCastException.java index 64d56e6438..26e5bf0c6b 100644 --- a/core-java/src/main/java/com/baeldung/classcastexception/ClassCastException.java +++ b/core-java/src/main/java/com/baeldung/classcastexception/ClassCastException.java @@ -8,14 +8,12 @@ public class ClassCastException { public static void main(String[] args) { - List> strList = new ArrayList>(); - // To correct the Exception at line #18, modify the line #11 code as: - // List> personList = new ArrayList >(); - // Line #18 code as personList.add(Arrays.asList(personArray)); String p1 = new String("John"); String p2 = new String("Snow"); String[] strArray = new String[] { p1, p2 }; - strList.add((ArrayList) Arrays.asList(strArray)); + ArrayList strList = (ArrayList) Arrays.asList(strArray); + // To fix the ClassCastException at above line, modify the code as: + // List strList = Arrays.asList(strArray); System.out.println("String list: " + strList); }