1 import java.util.ArrayList;
2 import java.util.List;
3
4 public class ListDemo {
5
6 /**
7 * @param args
8 */
9 public static void main(String[] args) {
10 // TODO Auto-generated method stub
11 List<Song> songs = new ArrayList<Song>();
12 songs.add(new Song("花好月圆",""));
13 songs.add(new Song("传奇",""));
14 songs.add(0,new Song("伤不起",""));
15 System.out.println(songs);
16 }
17
18 }
19 class Song{
20 String name;
21 String fileName;
22
23 public Song(String name) {
24 this.name = name;
25 }
26
27 public Song(String name, String fileName) {
28 this.name = name;
29 this.fileName = fileName;
30 }
31 @Override
32 public String toString() {
33 return this.name;
34 }
35 }
结果:s