InterfaceTo_LinkedList_Map1
Objectives:
  • Map<String, String> map1 = new HashMap<String, String>();
  • for(int i =0; i < strx.size(); i++)
    { map1.put(A1.str1[i],A1.str2[i]); }
  • Set<Entry<String, String>> set = map1.entrySet();
    Iterator<Entry<String, String>> it = set.iterator();
  • getKey(), getValue()
Notes :
  • entrySet

    Set<Map.Entry<K,V>> entrySet()
    Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll

 

 
Complete Code:

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

import javax.swing.JOptionPane;

import java.net.URI;
import java.util.*;
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 pp = new Process();
System.out.println(Process.a1face1);
System.out.println(Process.a1face1);
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()
{
String a1 = A11.first[0];
String a12 = A12.first[0];
System.out.println(a1 + " "+ a12);
LinkedList<String>strx = new LinkedList<String>
(Arrays.asList(A1.str1));
Map<String, String> map1 = new HashMap<String, String>();
for(int i =0; i < strx.size(); i++)
{ map1.put(A1.str1[i],A1.str2[i]); }
//
System.out.println("-----");
//System.out.println(map1);
Set<Entry<String, String>> set = map1.entrySet();
Iterator<Entry<String, String>> it = set.iterator();
while(it.hasNext())
{
Entry<String, String> me = it.next();
System.out.print(me.getKey()+ " : ");
System.out.print(me.getValue());
System.out.println();
}
}
}// 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 = "Common A11 interface";
String first[] = {"Java","A+","C#","XML",
"JSP","PHP","Z", "C#"};
}
interface A12{
int a11n1 = 20;
String a11face1 = "Common A11 interface";
String first[] = {"Oracle","sybase","MySQL",
"SQLLite","Json","CSV","ACCESS", "SQLServer"};
}
}

Runtime Views: