title: Counting most freq. user in an array
body: <pre><code>    int totalEnrolled = studentEnrollments.size();
      String mostFreqUser = "";
      int count = 0;
  
      System.out
              .println("~~~~~~~~~~~~~~~Spring 2016 Enrollment~~~~~~~~~~~~~~~");
  
      for (String userName : studentEnrollments.keySet()) {
          System.out.println("Student: " + userName);
          ArrayList&lt;String&gt; courses = studentEnrollments.get(userName);
          String courseMessage = "Courses: ";
          String seperator = "";
  
  
          // looping through courses
          for (String singleCourse : courses) {
              // counting how many courses were enrolled
              count++;
              courseMessage += seperator += singleCourse;
              System.out.println(courseMessage);
              seperator = ",";
          }
  
      }
  
  
      System.out.println("Total students enrolled: " + totalEnrolled);
      System.out.println("Total courses enrolled: " + count);
      System.out.println(mostFreqUser);
  }
  
  }
  </code></pre>
  
  <p>Hello, I was wondering how would I make a counter for the most frequent user. Everytime the for loop runs It would calculate who put there username the most. Also one more thing, how come the output prints multiple courses not just one for each name. For example instead of printing a course line for each courses it prints it twice.</p>
  
  <p>for example the expected output looks like </p>
  
  <p>Student: josh
  Courses: cs170, cs180</p>
  
  <p>but the output looks like</p>
  
  <p>Student: josh
  Courses:cs170
  Courses:cs170,cs170</p>
  
  <p>Thank you, please let me know if you need any more details.</p>