Java LinkedList size Example
LinkedList class size method example. This example shows you how to use size method.
LinkedList class size method example.public int size() Returns the number of elements in this list.
Her is the code
/**
* @ # Size.java
* A class repersenting use to size method of LinkedList class in java.util package
* version 15 May 2008
* author Rose India
*/
import java.util.*;
public class Size {
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");
//Size of the list
System.out.println("Size of the list = " + list.size());
}
} |
|