GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing www.tutorialspoint.com — Java LinkedHashSet Class
Selected Reading
Java LinkedHashSet ClassIntroductionThe Java LinkedHashSet class is a Hash table and Linked list implementation of the Set interface, with predictable iteration order.Following are the important points about LinkedHashSet −
Class declarationFollowing is the declaration for java.util.LinkedHashSet class − public class LinkedHashSet<E> extends HashSet<E> implements Set<E>, Cloneable, Serializable ParametersFollowing is the parameter for java.util.LinkedHashSet class − E − This is the type of elements maintained by this set. Class constructors
Class methods
This class inherits methods from the following classes −
Getting a Spliterator() to Iterate Entries of LinkedHashSet ExampleThe following example shows the usage of Java LinkedHashSet spliterator() method to iterate entries of the LinkedHashSet. We've created a LinkedHashSet object of Integer. Then few entries are added using add() method and then an spliterator is retrieved using spliterator() method and each value is printed by iterating through the spliterator. package com.tutorialspoint;
import java.util.LinkedHashSet;
import java.util.Spliterator;
public class LinkedHashSetDemo {
public static void main(String args[]) {
// create hash set
LinkedHashSet <Integer> newset = new LinkedHashSet <>();
// populate hash set
newset.add(1);
newset.add(2);
newset.add(3);
// create an spliterator
Spliterator<Integer> spliterator = newset.spliterator();
// check values
spliterator.forEachRemaining(v -> System.out.println(v));
}
}
Let us compile and run the above program, this will produce the following result. 1 2 3 Advertisements
| ||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |