java - Inner Hashtable Overwriting -


I'm working on hashtable. In which I want to make a hashtable but my values ​​of the outer hashtable are being replaced.

hashtable1 [key, hashtable [key, value]]

I am able to get the external vertical key without overwritten, but the internal hashtable values ​​are being replaced

< Ex> Import java.io. *; Import java.util. *; Import com.sridhar.util *; Public class MyTokenizerDemo {Public Static Zero Main (string [] Argos throws IOException {Hashtable ht = new Hashtable (); Hashtable HT1 = New HashTable (); Hashtable HT2 = new hashtable (); File f = new file ("E: / rum / format.txt"); FileReader fr = New FileReader (f); Buffett reader BR = new buffed reader (FR); String s; While ((s = br.readline ()) = null {ArrayList aList = (ArrayList) StringUtils.myTokenizer (s, "~! ~"); For (int i = 0; i & lt; aList.size ( ); I ++) {Aare list aList1 = (ArrayList) StringUtils.myTokenizer (string) aList.get (i), "$ # $"); //System.out.println("==>"+ AList1.get (0) + "& lt; =="); ArrayList aList2 = (ArrayList) StringUtils.myTokenizer ((string) aList1.get (1), "~ $ ~"); //System.out.println ( "====>" + aList2 + "& lt; ====="); for (int j = 0; j & lt; aList2.size (); j ++) {as array = ( ArrayList StringTholes.MyOkInezer (string) aList2.get (j), "# $ #"); If (as! = Null) {string innerkey = (string) as.get (0); string inherval = (string) As.get (1); ht2.put (innerkey, innervalue);}} Ht1.put (aList1.get (0 ), HT2);}} System.out.println (ht1);}

}

Please make a perception utility class token on my own string

Overwriting my external Hesbat values.

Help me with this problem.

Change this lin code to code ht1.put (AList1.get (0), Ht2); as ht1.put (aList1.get (i), ht2);

When you call asList1 (0), always the key will be the same, so your data will be overridden


Comments

Popular posts from this blog

eclipse plugin - Run java code error: Workspace is closed -

ios - How do I use CFArrayRef in Swift? -

scala - Play Framework - how to bind form to a session field -