Type mismatch: cannot convert from void to ArrayList<String>
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Why am I getting this error for this code? I have the correct imports for ArrayList an Collections private ArrayList<String> tips; public TipsTask(ArrayList<String> tips){ this.tips = Collections.shuffle(tips); } 回答1: Collections.shuffle(tips); Collections.shuffle return void, you cannot assign void to a ArrayList . you could do for example: 回答2: The problem is that Collections.shuffle method doesn't return anything. You can try this: private ArrayList<String> tips; public TipsTask(ArrayList<String> tips){ this.tips = new ArrayList<String>