How to insert string array into LinkedList in Java

1 Answer

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

public class MyClass {
    public static void main(String args[]) {
        String[] arr = {"java", "c", "c++", "c#", "python"}; 
       
        LinkedList ll = new LinkedList(Arrays.asList(arr));
 
        ll.forEach(System.out::println);
    }
}
 
 
 
 
/*
run:
 
java
c
c++
c#
python

*/

 



answered Apr 1, 2021 by avibootz

Related questions

1 answer 164 views
2 answers 230 views
1 answer 158 views
3 answers 193 views
1 answer 158 views
...