How Convert Array to LinkedList

import java.util.Arrays;
import java.util.LinkedList;

public class ArrayToLinkedList {

public static void main(String[] args) {

String [] arr = {“php”,”cpp”,”java”,”html”};

LinkedList<String> list = new LinkedList<String>(Arrays.asList(arr));

for (String str : list) {
System.out.println(“element is = “+str);

}

}

}

Output:

element is = php

element is = cpp

element is = java

element is = html

Leave a Reply

Your email address will not be published. Required fields are marked *

− 1 = 9