Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> import java.util.*;
> Map<String, Integer> a = new HashMap<String, Integer>(); 
> a
{}
> a.put("bob", 2)
null
> a
{bob=2}
> a.put("laura", 3)
null
> a
{laura=3, bob=2}


--

import java.util.*; 

public class Profile {
  public static void main(String[] args) {
    String word = args[0]; 
    Map<String, Integer> a = new HashMap<String, Integer>(); 
    for (int i = 0; i < word.length(); i++) {
      String letter = word.substring(i, i+1);
      a.put(letter, 10); 
      System.out.println( a ); 
    }
  }
}

--

Now we modify this:

import java.util.*; 

public class Profile {
  public static void main(String[] args) {
    String word = args[0]; 
    Map<String, Integer> a = new HashMap<String, Integer>(); 
    for (int i = 0; i < word.length(); i++) {
      String letter = word.substring(i, i+1);
      int count = 0; 
      if (a.get(letter) != null)
        count = a.get(letter); 
      a.put(letter, count + 1); 
      System.out.println( a ); 
    }
  }
}

--

Here's how it works:

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> java Profile banana
{b=1}
{a=1, b=1}
{a=1, b=1, n=1}
{a=2, b=1, n=1}
{a=2, b=1, n=2}
{a=3, b=1, n=2}


--

For Lab 08 the plan is:

(a) read the file, create a map of frequencies

(b) define a comparable type, convert the map to an array list of those

(c) sort the array list and report the results

In lab the AIs will review these steps at the beginning of the lab. 

See you then!

--

https://www.cs.indiana.edu/~dgerman/items/result003.pdf