Example & Tutorial understanding programming in easy ways.

Simple Example of LinkedHashMap class in Java .

import java.util.*;

class Test7{

public static void main(String args[]){

LinkedHashMap hm=new LinkedHashMap();

hm.put(2,"Amit");

hm.put(1,"Amar");

hm.put(3,"Rahul");

hm.put(2,"Alok");

Set set=hm.entrySet();

Iterator itr=set.iterator();

while(itr.hasNext()){

Map.Entry m=(Map.Entry)itr.next();

System.out.println(m.getKey()+" "+m.getValue());

}}}

Output: 2 Alok
             1 Amar
             3 Rahu

Read More →