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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s