Advertisement
cd62131

2-index string

Feb 16th, 2014
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.66 KB | None | 0 0
  1. import java.util.Map;
  2. import java.util.Map.Entry;
  3. import java.util.TreeMap;
  4.  
  5. public class StringList {
  6.   public static void main(String[] args) {
  7.     String[] s = {"ABC", "DEF", "GHI"};
  8.  
  9.     Map<Integer, Map<Integer, String>> map =
  10.       new TreeMap<Integer, Map<Integer, String>>();
  11.     map.put(0, new TreeMap<Integer, String>());
  12.     for (int i = 0; i < s.length; i++)
  13.       map.get(0).put(i, s[i]);
  14.  
  15.     s[2] = "222";
  16.  
  17.     for (String e: s)
  18.       System.out.println(e);
  19.  
  20.     for (Entry<Integer, Map<Integer, String>> e: map.entrySet())
  21.       for (Entry<Integer, String> ee: e.getValue().entrySet())
  22.         System.out.println(ee.getValue());
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement