tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Google Guava > Collections > New Linked HashSet

New Linked HashSet 

Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using Sets.newLinkedHashSet() API. It returns a mutable LinkedHashSet object containing the given elements in order.

File Name  :  
Author  :  Sudhakar KV
Email  :  [email protected]
package com.bethecoder.tutorials.guava.collection_tests;

import java.util.Arrays;
import java.util.Set;

import com.bethecoder.tutorials.guava.common.Student;

public class NewLinkedHashSetTest {

   @param args
  public static void main(String[] args) {
    Set<String> stringSet = Sets.newLinkedHashSet(Arrays.asList("ONE""TWO""THREE"));
    Set<Integer> intSets = Sets.newLinkedHashSet(Arrays.asList(1234));
    Student student = new Student("Sriram"2"Chess");
    Student student2 = new Student("Venkat"28"Cricket");
    Set<Student> studSets = Sets.newLinkedHashSet(Arrays.asList(student, student2));


It gives the following output,
[1, 2, 3, 4]
[[email protected], 
	[email protected]]


bl  br