Guest User

Solution for task 2 of challenge "Changing course"

a guest
Feb 25th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. public Map<String, Video> videosByTitle(Course course) {
  2.     Map<String, Video> videoMap = new HashMap(); // Create a new Map, remember to import java.util.HashMap at the top of the file
  3.     for(Video video : course.getVideos()) { // Loop though each of the Video objects in the course's Video list
  4.         videoMap.put(video.getTitle(), video); // Add an entry to the map where the value is the title of the Video and the key the Video
  5.     }
  6.     return videoMap; // Return this new Map
  7. }
Advertisement
Add Comment
Please, Sign In to add comment