Java Tutorial: Linked List with Threads


hi,

In this Tutorial You will get to know how easy linkedlist is to use in java.

to create new linked list named name just type.

LinkedList name= new LinkedList()

name.add(“ur content”)l              to add content

refer to following code,

import java.util.*;

public class linkedlist{

public static void main(String argv[])
{
LinkedList name= new LinkedList();
name.add(“sonawane”);
name.addFirst(“bhushan”);
name.add(1, “bhalchandra”);
System.out.println(“content of name “+name);
name.set(0,” BhUsHaN”);
System.out.println(“content of name after setting  “+name);
String frnd[]={“rohit”,”rohini”,”aanchal”,”ojas”,”chinmoy”};
LinkedList fr=new LinkedList();

for(int i=0;i<5;i++)
{
fr.add(i, frnd[i]);
}
System.out.println(“content of frnds “+fr);

for(int i=0;i<5;i++)
{
System.out.println(fr.get(i)+” removed”);
fr.remove(i);

}

System.out.println(“content of frnds after removing “+fr);

System.out.println(“this wont print \n No content in fr linkedlist if you want to see how this gives error just comment try&catch”);

}

}

same program but includes threading here,

Linkedlist&thread

Leave a comment