d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Adding Elements To Treesets
Add Reply New Topic New Poll
Member
Posts: 24,101
Joined: Nov 8 2007
Gold: 5,561.70
Jun 27 2012 07:43pm
No idea why my code isn't working, supposed to add a song to the TreeSet allSongs, but it never adds more than the first one.

A Song is defined as a name and duration

Anyone know why this won't work

Code

public MPlayer() {
 allSongs = new TreeSet<Song>();
 playLists = new TreeMap<String, ArrayList<String>>();
}

/**
 * Adds song to the database.
 * @param name
 * @param durationInSeconds
 * @return
 */
public Mplayer addSong(String name, int durationInSeconds) {
 allSongs.add(new Song(name, durationInSeconds));
 return this;
}


-_-
Member
Posts: 649
Joined: May 28 2012
Gold: 14.00
Jun 28 2012 02:55am
1. post the rest of the code (how are you testing it)
2. why "return this;" ???
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll