java char array to array list code example
Example 1: convert every character in string to arraylist jva
import java.util.ArrayList;
import java.util.List;
// Convert a String to a List of Characters
class Util
{
public static void main(String[] args)
{
String string = "Techie Delight";
List<Character> chars = new ArrayList<>();
for (char ch: string.toCharArray()) {
chars.add(ch);
}
System.out.println(chars);
}
}
Example 2: char array to arraylist java
myString.chars().mapToObj(c -> (char) c).collect(Collectors.toList());