Movie a = new Movie("The Muppets Take Manhattan", "Columbia Tristar", 2001); Movie b = new Movie("Fight Club", "Regency Enterprises", 1999); Movie c = new Movie("Toy Story", "Walt Disney Pictures", 1995); Movie[] movies = {a, b, c}; // compares the TITLES in ASCENDING order Arrays.sort(movies, new Comparator<Movie>() { public int compare(Movie m1, Movie m2) { return m1.getTitle().compareTo(m2.getTitle()); } }); // print out the sorted movie array for (Movie m : movies) { System.out.println(m + "\n---"); }
this.movieLibrary.put(item.getTitle(), item);