Answers for "creating character list in java"

0

saving String character in arraylist

//storing String character in arraylist
import java.util.*;
public class Basic_Practice2 {
	public static void main(String[] args) {
		
		String s = "Hello";
      
		ArrayList<String> al = new ArrayList<String>();
      //storing String character in arraylist
		for(int i = 0; i < s.length(); i++)
			{
				al.add(Character.toString(s.charAt(i)));
			}
      // printing ArrayList
		System.out.println(al);//[H,e,l,l,o]
		
	}
}
Posted by: Guest on May-04-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language