5:25 am - Wednesday February 21, 2018

LinkedList Example Program for getFirst()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
Author :candidjava.com
Description: Returns the first element  in the list.
*/
import java.io.IOException;
import java.util.*;
public class LinkedListGetFirst
 {
public static void main(String args[])
{
int b=60,c=20,d=30;
LinkedList l=new LinkedList();
l.add(b);
l.add(c);
l.add(d);
System.out.println("First element in the list is");
System.out.println(l.getFirst());
}
}

 

Output:

First element in the list is
60

Filed in: Core Java Tutorial

Comments are closed.