Same error with E, T example https://code.sololearn.com/cmNQH014sVF0/?ref=app
11/25/2021 9:15:05 PM
Billy Beagle3 Answers
New AnswerYou could use these for arrays char[] arr = {'2', '5'}; ArrayList<Character> list = new ArrayList<Character>(); for (char ch: arr) list.add(ch); or Character[] arr = {'2', '5'}; ArrayList<Character> list = new ArrayList<>(Arrays.asList(arr)); or Character[] arr = {'2', '5'}; ArrayList<Character> list = new ArrayList<>(); list.addAll(Arrays.asList(arr)); This is the result. for (char i : list) System.out.println(i); or for (Character i : list) System.out.println(i); // Keep learning & happy coding :D
I think asList doesn't work for char arrays. Maybe try ArrayList<Character> li = new ArrayList<Character>(); for (char ch: arr) { li.add(ch); }
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message