8:04 am - Sunday August 20, 2017

LinkedList Example Program for removeFirst()

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

/**
*LinkedList Example Program for removeFirst()
* @author   candidjava.com
* @description:  Removes first element of the linkedlist .
*/

import java.util.LinkedList;

public class List {
public static void main(String args[]) {
LinkedList l = new LinkedList();// creats objects for linkedlist
l.add("e");// add elements in the list.
l.add("f");
l.add("d");
l.add("s");
l.add("a");
l.add("d");
System.out.println("before removing" + l);
l.removeFirst();// this method removes first element from list.
System.out.println("After removing first occurrence " + l);

}
}



Output:
before removing[e, f, d, s, a, d]
After removing first occurrence [f, d, s, a, d]

BACK

Filed in: Z-A All Java Codes

Comments are closed.