java string to char arraylist code example

Example 1: arraylist of characters

import java.util.ArrayList;

  public class Test{

       String words = new String("HELLO GOODBYE!");
       ArrayList<Character> sample = new ArrayList<Character>();

       for(int i = 0; i<words.length(); i++){
           sample.add(words.charAt(i));
       }
  }

Example 2: Arraylist string to character java

String str = "abcd...";
ArrayList<Character> chars = new ArrayList<Character>();
for (char c : str.toCharArray()) {
  chars.add(c);
}

Example 3: char array to arraylist java

myString.chars().mapToObj(c -> (char) c).collect(Collectors.toList());

Example 4: char arraylist java

ArrayList<Character> operations = new ArrayList<Character>();