1String [] strings = new String [] {"1", "2" };
2List<String> stringList = new ArrayList<String>(Arrays.asList(strings)); //new ArrayList is only needed if you absolutely need an ArrayList
3
1//storing String character in arraylist
2import java.util.*;
3public class Basic_Practice2 {
4 public static void main(String[] args) {
5
6 String s = "Hello";
7
8 ArrayList<String> al = new ArrayList<String>();
9 //storing String character in arraylist
10 for(int i = 0; i < s.length(); i++)
11 {
12 al.add(Character.toString(s.charAt(i)));
13 }
14 // printing ArrayList
15 System.out.println(al);//[H,e,l,l,o]
16
17 }
18}
1import java.util.ArrayList;
2import java.util.List;
3import java.util.Arrays;
4public class JavaExample {
5 public static void main(String args[]){
6 String num = "22,33,44,55,66,77";
7 String str[] = num.split(",");
8 List<String> al = new ArrayList<String>();
9 al = Arrays.asList(str);
10 for(String s: al){
11 System.out.println(s);
12 }
13 }
14}