Convert LinkList To ArrayList in Java
Convert LinkList To ArrayList in Java:
package one;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class LinkToArray {
public static void main(String[] args) {
LinkedList<String> linkedlist = new LinkedList<String>();
linkedlist.add("Sifat");
linkedlist.add("mohaiminur");
linkedlist.add("huda");
linkedlist.add("sakib");
linkedlist.add("robi");
List<String> list = new ArrayList<String>(linkedlist);
for (String str : list){
System.out.println(str);
}
}
}
package one;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class LinkToArray {
public static void main(String[] args) {
LinkedList<String> linkedlist = new LinkedList<String>();
linkedlist.add("Sifat");
linkedlist.add("mohaiminur");
linkedlist.add("huda");
linkedlist.add("sakib");
linkedlist.add("robi");
List<String> list = new ArrayList<String>(linkedlist);
for (String str : list){
System.out.println(str);
}
}
}
Comments
Post a Comment