I know how to run again on a Hashp, but I'm not sure that we set 2 ether's set on a heashmap Can or not?
Say I have the following hampapa:
map m = new hashmap I want to add all the values outside the Hasmap so that some pair can be repetitive. So in this case, 4 values - & gt; 6 pairs (AB, AC, AD, BC, BD, CD). I'm thinking of something like:
for (int i = 0; i & lt; (size -1); i ++) for (int l = 1; & lt ; Size; l ++) ... But how do I use the Iterator if I use the Iterator in Java? (If you can find a way to use the set index which will also be fine)
PS: Sorry, I have just moved from C ++ to Java, so let me start your help. would be required.
Ensure that the values implement comparative string tool Comparative & lt; String & gt; So you're okay (if you want, read some tutorials about comparative).
Maps & lt; Integer, string & gt; Use (X, X) and (Y, X) to exclude. Map = new hashmap & lt; Integer, string & gt; (); Map.put (112,334, 'A'); Map.put (221,345, 'B'); Map.put (321,411, 'C'); Map.put (431,254, 'd'); Collections & lt; String & gt; Value = map.values (); (String str1: value) {for (strings str2: value) {if (str1.compareTo (str2) <0} {System.out.println (String.format ("Unique pair: (% s,% s) ", Str1, str2)); // or do not modify the map you want here! }}}
No comments:
Post a Comment