Showing posts with label how to make linkedlist from array. Show all posts
Showing posts with label how to make linkedlist from array. Show all posts

Sunday, 17 May 2015

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