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 trialQuentin Quarles
1,900 PointsKaraokeMachine.java compilation error
When I try to compile, I get the following errors:
./com/teamtreehouse/KaraokeMachine.java:88: error: unmappable character for encod
ing ASCII
private Song promptSongForArtist(String artist) throws IOException{???
./com/teamtreehouse/KaraokeMachine.java:88: error: unmappable character for encod
ing ASCII
private Song promptSongForArtist(String artist) throws IOException{???
./com/teamtreehouse/KaraokeMachine.java:88: error: unmappable character for encod
ing ASCII
private Song promptSongForArtist(String artist) throws IOException{???
^
./com/teamtreehouse/KaraokeMachine.java:88: error: unmappable character for encod
ing ASCII
private Song promptSongForArtist(String artist) throws IOException{???
^
./com/teamtreehouse/KaraokeMachine.java:88: error: unmappable character for encod
ing ASCII
I used the code as presented in the video lectures
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()); } int index = promptForIndex(songTitles); return songs.get(index); }
1 Answer
Valerie O. Okpoko
9,721 PointsYou are getting the errors because you left out the <type> in the declaration of the List variable. As part of the syntax for declaring a List variable, you must put its type in an angle brace <>. Try using the following codes:
private Song promptSongForArtist(String artists) throws IOException { List<Song> songs = mSongBook.getSongsForArtist(artists); //<Song> is the data type of List variable songs List<String> songTitles = new ArrayList<> (); //<String> is the data type of List variable songTitles for(Song song: songs) { songTitles.add(song.getTitle() ); } int index = promptForIndex(songTitles); return songs.get(index); }
James Reynolds
3,325 PointsJames Reynolds
3,325 PointsPost your code from KaraokeMachine.java. https://teamtreehouse.com/community/posting-code-to-the-forum Did you use a try/catch in your run() method?