for (String userName : studentEnrollments.keySet()) {
System.out.println("Student: " + userName);
ArrayList<String> courses = studentEnrollments.get(userName);
String courseMessage = "Courses: ";
for (String singleCourse : courses) {
courseMessage += singleCourse + ", ";
System.out.println(courseMessage);
}
}
After the for loop, it prints out each courses the student is taking. What is the proper way to print out the string with commas without the last comma at the end?
For example: AC130, AC140, AC150, to AC130, AC140, AC150