请老师帮我看一下这是什么原因?

请老师帮我看一下这是什么原因?

这么做的话,出现了一个问题,倒数第三行报错了:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//测试播放器
public static void testPlayListCollection() {
     
    Song s1 = new Song("a001","星晴","周杰伦");
    Song s2 = new Song("a002","十年","陈奕迅");
    Song s3 = new Song("a003","妹妹你大大滴往前走","不知道");
     
    //音乐打包
    List<Song> playList = new ArrayList<Song>();
    playList.add(s1);
    playList.add(s2);
    playList.add(s3);
     
    PlayList pl1 = new PlayList("我的收藏",playList);
     
    //列表打包
    Map<String,PlayList> playListMap = new HashMap<String,PlayList>();
    playListMap.put(pl1.getPlayListName(), pl1);
     
    PlayListCollection plc1 = new PlayListCollection(playListMap);
     
    PlayList pl2 = new PlayList("我的收藏2",playList);
    plc1.addPlayList(playList);//
     
    System.out.println("显示所有播放列表名称:");
    plc1.displayPlayListName();
     
}

这是PlayListCollection类的内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package zuoye;
 
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
 
public class PlayListCollection {
 
    //为什么选Map类型
    private Map playListMap;
 
    public PlayListCollection(Map playListMap) {
        this.playListMap = playListMap;
        this.playListMap.put("主列表",null);
    }
 
    public Map getPlayListMap() {
        return playListMap;
    }
 
    public void setPlayListMap(Map playListMap) {
        this.playListMap = playListMap;
    }
     
    //添加播放列表
    public void addPlayList(PlayList playList) {
        playListMap.put(playList.getPlayListName(),playList);
    }
     
    //删除播放列表
    public void deletePlayList(PlayList playList) {
         
    }
     
    //通过名字查询
    public PlayList searchPlayListByName(String playListName) {
         
    }
     
    //显示所有播放列表名称
    public void displayPlayListName() {
         
        Set<Entry<String,PlayList>> entrySet = playListMap.entrySet();
        for(Entry<String,PlayList> entry:entrySet) {
            System.out.println(entry.getKey());
        }
    }
     
     
}


正在回答

登陆购买课程后可参与讨论,去登陆

1回答

 plc1.addPlayList(playList);报错?你看一下PlayListCollection类中的addPlayList()定义的地方需要传入什么类型的数据?是不是应该是PlayList类型的?是不是pl2呀?祝:学习愉快

  • 专业躺鸡 提问者 #1
    老师~ 我重新编辑了一下提问内容~
    2017-08-25 11:39:11
  • 专业躺鸡 提问者 #2
    不好意思,不好意思,早上有点蒙X了 看什么都晕晕了,我看错了。囧
    2017-08-25 11:41:56
  • 专业躺鸡 提问者 #3
    非常感谢!
    2017-08-26 19:24:24
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师
插入代码