❮ Previous Next ❯

LinkedList:

voidaddFirst();
voidaddLast();
Object getFirst();
Object getLast();
Object removeFirst();
Object removeLast();

Constructors:

Example :LinkedListDemo.java:

import java.util.*;
class LinkedListDemo
{
public static void main(String[] args)
{
LinkedList l=new LinkedList();
l.add("Tapuuu");
l.add("Mona");
l.add("Divya");
l.add(25);
l.add(null);
System.out.println(l);
Iterator it=l.iterator();
while(it.hasNext())
{
Object o1=it.next();
System.out.println(o1);
}
l.addFirst("Tilan");
l.addLast("Kandhei");
System.out.println(l);
l.remove(5);
l.removeFirst();
l.removeLast();
System.out.println(l);
}
}

Output

[Tapuuu,Mona,Divya,25,null]
Tapuuu
Mona
Divya
25
Null
[Tilan,Tapuuu,Mona,Divya,25,null,Kandhei]
[Tapuuu,Mona,Divya,25]

ArrayList vs. LinkedList:

ArrayList:

LinkedList:

❮ Previous Next ❯



  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved