1 import java.util.*;
2
3 public class TestArgsWords {
4
5 public static void main(String args[]) {
6 Map<String, Integer> m = new HashMap<String, Integer>();
7
8 for (int i = 0; i < args.length; i++) {
9 int freq = (Integer) m.get(args[i]) == null ? 0 : (Integer) m.get(args[i]);
10 m.put(args[i], freq==0 ? 1 : freq + 1);
11 }
12
13 System.out.println(m.size() + " distinct words detected:\n"+m);
14 }
15 }
16
2
3 public class TestArgsWords {
4
5 public static void main(String args[]) {
6 Map<String, Integer> m = new HashMap<String, Integer>();
7
8 for (int i = 0; i < args.length; i++) {
9 int freq = (Integer) m.get(args[i]) == null ? 0 : (Integer) m.get(args[i]);
10 m.put(args[i], freq==0 ? 1 : freq + 1);
11 }
12
13 System.out.println(m.size() + " distinct words detected:\n"+m);
14 }
15 }
16