Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,914 questions

51,847 answers

573 users

How to convert String array to ArrayList in Java

5 Answers

0 votes
import java.util.Arrays;
import java.util.List;

public class MyClass {
    public static void main(String args[]) {
        String[] strArr = new String[]{"Java", "PHP", "C", "C++", "C#", "Python"};
 
        List<String> listStrArr = Arrays.asList(strArr);  
 
        for (String e : listStrArr) {
            System.out.println(e);  
        }
    }
}





/*
run:

Java
PHP
C
C++
C#
Python

*/

 



answered Oct 23, 2016 by avibootz
edited Oct 9, 2023 by avibootz
0 votes
import java.util.Arrays;
import java.util.List;

public class MyClass {
    public static void main(String args[]) {
        String[] strArr = new String[]{"Java", "PHP", "C", "C++", "C#", "Python"};
 
        List<String> listStrArr = Arrays.asList(strArr);  
 
        listStrArr.stream().forEach((e) -> {
            System.out.println(e);  
        });
    }
}





/*
run:

Java
PHP
C
C++
C#
Python

*/

 



answered Oct 23, 2016 by avibootz
edited Oct 9, 2023 by avibootz
0 votes
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MyClass {
    public static void main(String args[]) {
        List<String> al = new ArrayList(Arrays.asList(new String[]{"Java", "PHP", "C", "C++"}));
 
        al.stream().forEach((e) -> {
            System.out.println(e);  
        });
    }
}





/*
run:

Java
PHP
C
C++

*/

 



answered Oct 23, 2016 by avibootz
edited Oct 9, 2023 by avibootz
0 votes
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
 
public class MyClass {
    public static void main(String args[]) {
        String[] strArr = new String[]{"Java", "PHP", "C", "C++", "C#", "Python"};
   
        List<String> al = new ArrayList();
   
        Collections.addAll(al, strArr);
           
        for (String e : al) {
            System.out.println(e);  
        }
    }
}
 
 
 
 
 
/*
run:
 
Java
PHP
C
C++
C#
Python
 
*/

 



answered Oct 24, 2016 by avibootz
edited Oct 9, 2023 by avibootz
0 votes
import java.util.ArrayList;
import java.util.Arrays;

public class MyClass {
    public static void main(String args[]) {
        String[] stringArray = new String[]{"Java", "PHP", "C", "C++", "C#", "Python"};
   
        ArrayList<String> al = new ArrayList<>();
        
        al.addAll(Arrays.asList(stringArray));
           
        for (String e : al) {
            System.out.println(e);  
        }
    }
}
 
 
 
 
 
/*
run:
 
Java
PHP
C
C++
C#
Python
 
*/

 



answered Oct 9, 2023 by avibootz

Related questions

5 answers 411 views
2 answers 283 views
1 answer 160 views
1 answer 116 views
1 answer 145 views
1 answer 121 views
1 answer 211 views
...