InterfaceTo_LinkedHasSet1
Objectives :
  • LinkedHashSet,  extends HashSet
  • LinkedHashSet maintains a linked list of the elements added to the set, and  in the order of inserting elements. This allows insertion-order iteration over the set.
  • Has three constructors
    • LinkedHashSet()
    • LinkedHashSet(int capacity)
    • LinkedHashSet(int capacity, float fillRatio)

Complete Code:

/**
*
*/
import java.io.*;

import javax.swing.JOptionPane;

import java.net.URI;
import java.util.*;
//import java.util.stream.*;//
import java.util.Map.Entry;
/**
* @author Manas9
*
*/
public class ClassTemplate1 {
/**
*
*/
public ClassTemplate1() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args)
throws Exception {
// TODO Auto-generated method stub]
try {
Process.roller();
//
} catch (NumberFormatException exc) {
//Process
}
}
}// end of class template
//
//Process implements interface A1
class Process implements A1
{
public Process()
{ System.out.println("Default) constructor");}
public static void roller()
{
//Set<String> set1 = new HashSet<String>(Arrays.asList(A1.str1));
Set<String> set2 = new HashSet<String>(Arrays.asList(A1.str2));
LinkedHashSet<String> ll1 = new LinkedHashSet<String>(Arrays.asList(A1.str1));
LinkedHashSet<String> ll2 = new LinkedHashSet<String>();
System.out.println("Original Arrays.asList(A1.str1)");
System.out.print("\t");
for(String strx1 : ll1)
{ System.out.print(strx1 + " "); }
System.out.println();
//
for(String strx2 : set2)
{ ll2.add(strx2) ;}
System.out.println();
System.out.println("Printing Flat");
System.out.println(ll2);
System.out.println();
System.out.println("iterate with for each loop");
//iterate with for each loop
for(Object obj1:ll2)
{
System.out.print(" " +obj1);
}
}
}// end of Class Process
// interfaces
interface A1 {
int a1n1 = 10;
String a1face1 = A11.a11face1;

String a1face2 = A12.a11face1;
String[] str1 = (A11.first);
String[] str2 = (A12.first);
interface A11{
int a11n1 = 20;
String a11face1 = "C#";
String first[] = {"Java","A+","C#","XML",
"JSP","PHP","Z", "C#", "A+"};
}
interface A12{
int a11n1 = 20;
String a11face1 = "Oracle";
String first[] = {"Oracle","sybase","MySQL",
"SQLLite","Json","CSV","ACCESS","A+", "SQLServer"};
}
}

 
Runtime Views: