maps - aps aps Maps Maps et's add variables to our simple...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: aps aps Maps Maps et's add variables to our simple calculator Let s add variables to our simple calculator. A variable should store a number. A = 7 > A = 7 ==> A = 7 > 3 * (A + 5) ==> 36 uilding a concordance uilding a concordance Building a concordance Building a concordance ow to print the map ow to print the map How to print the map How to print the map The Map interface allows to return all the key values in the map in a Set . A Set is another ADT (Java interface). It represents-no big surprise-a set of objects. To look at all the elements of a Set, we use an iterator . Set<String> keys = map.keySet(); Iterator<String> it = keys.iterator(); while (it.hasNext()) { String k = it.next(); System.out.println(k + "\t: " + map.get(k)); } In what order are the elements of the set returned by the iterator? Getting rid of duplicated line Getting rid of duplicated line numbers numbers ap<String, List<Integer>> map = Map<String, List<Integer>> map new TreeMap<String, List<Integer>>(); // ......
View Full Document

Page1 / 6

maps - aps aps Maps Maps et's add variables to our simple...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online