Java LinkedList set Example
LinkedList class set method example. This example shows you how to use set method.
LinkedList class set method example.public LinkedList set(int index, E element) Replaces the element at the specified position in this list with the specified element.
Here is the code
/**
* @ # Set.java
* A class repersenting use to set method of LinkedList class in java.util package
* version 15 May 2008
* author Rose India
*/
import java.util.*;
public class Set {
public static void main(String args[]) {
LinkedList list = new LinkedList();
int i = 11;
String str = "Rose";
//Add the specified element to the end of this list.
list.add(i);
list.add(str);
list.add("India");
//Replaces the element
list.set(0, 356);
System.out.println(list);
}
} |
|