8:41 pm - Monday June 26, 2017

LinkedList Example Program for set(int index, E element)

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 set(int index, E element)
/**

* @author   candidjava.com
* @description: Replaces the element at the specified position in this list with the specified            element.
*/

import java.util.*;

public class Lie2 {
public static void main(String args[]) {
LinkedList l = new LinkedList();// creats objects for linkedlist.
l.add(1);
l.add(3);// add the elements.
l.add(4);
l.add(6);

System.out.println("Elements of the list" + l);
l.set(1, "g");// this method is used for to replaces the element at the
// specified position in this list with the specified
// element.
System.out.println("after replace" + l);
}
}


Output:
Elements of the list[1, 3, 4, 6]
after replace[1, g, 4, 6]

BACK

Filed in: Z-A All Java Codes

Comments are closed.