Type mismatch: cannot convert from void to ArrayList

后端 未结 6 1326
别跟我提以往
别跟我提以往 2021-01-21 03:54

Why am I getting this error for this code? I have the correct imports for ArrayList an Collections

private ArrayList tips;

public TipsTask(ArrayLi         


        
6条回答
  •  广开言路
    2021-01-21 04:01

    Collections.shuffle(tips) returns void. So you cannot assign this to an ArrayList()

    What you want is

    private ArrayList tips;
    
    public TipsTask(ArrayList _tips){
        Collections.shuffle(_tips);
        this.tips = _tips;
    }
    

提交回复
热议问题