Hi
I am using array of hashtables.I am putting some key-value in the zeroth
position of the array hashtable and 1st position of the hashtable.My code is given belowi am getting the output as
0
Keys=w2 Value=0.2
Keys=w1 Value=0.1
Keys=w4 Value=0.4
Keys=w3 Value=0.3
************
but i want the value to be displayed as
0 //oth element of the array hashtable
Keys=w2 Value=0.2
Keys=w1 Value=0.1
1 //1st elemtn of the array hashtable
Keys=w4 Value=0.4
Keys=w3 Value=0.3
************
public class
test {
static Hashtable template= new Hashtable();
static Hashtable arrtable[]= new Hashtable[2];
public static void main(
String args[])
{
int m=0;
template.put("w1", "0.1");
template.put("w2", "0.2");
arrtable[m]=template;
m++;
clear();
template.put("w3", "0.3");
template.put("w4", "0.4");
arrtable[m]=template;
clear();
displayValues();
}
public static void displayValues()
{
int m=0;
System.out.println(m);
for(Iterator n=arrtable[m].entrySet().iterator(); n.hasNext(); )
{
Map.Entry e = (Map.Entry) n.next();
System.out.println("Keys=" + e.getKey() + " Value=" + e.getValue());
m++;
}
System.out.println("************");
}
private static void clear()
{
Hashtable template = new Hashtable();
}
}