Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialhsin Yang
1,014 Pointsmissing the get method
return Song.get(index); The get method is red, and it ask me to create a get method. Somehow my Song.java is missing the get method. Can anyone help me with this ? This is KaraokeMachine Code: private Song promptSongForArtist(String artist) throws IOException { List<Song> songs = mSongBook.getSongsForArtist(artist); List<String> songTitles = new ArrayList<>(); for (Song song : songs) { songTitles.add(song.getTitle()); } System.out.printf("Available songs for %s: %n", artist); int index = promptForIndex(songTitles); return Song.get(index); }
3 Answers
Fahad Mutair
10,359 Pointshi hsin Yang , you typed wrong return statement ,you should return songs NOT Song
return songs.get(index);
hsin Yang
1,014 PointsMy class itself is song instead of songs
Fahad Mutair
10,359 Pointshere you have to return the object not the class, so songs is your object
hsin Yang
1,014 Pointsokayy!! I see! Thank you!