如何将布尔数组添加到布尔列表?

时间:2015-12-01 08:53:24

标签: boolean

我正在尝试这样做:

    NewRoomate(int studentID, List<Integer> rankedQuestions, boolean...trueFalseQuestions){ 
        this.studentID = studentID;
        this.rankedQuestions = rankedQuestions;
        List<Boolean> wef = Arrays.asList(trueFalseQuestions);
    }

但是编译器不喜欢它。 问题:enter image description here

如何将trueFalseQuestions数组中的所有布尔值转换为List?

3 个答案:

答案 0 :(得分:1)

boolean...trueFalseQuestions更改为Boolean...trueFalseQuestions

结果将是:

NewRoomate(int studentID, List<Integer> rankedQuestions, Boolean...trueFalseQuestions){ 
    this.studentID = studentID;
    this.rankedQuestions = rankedQuestions;
    List<Boolean> wef = Arrays.asList(trueFalseQuestions);
}

答案 1 :(得分:0)

NewRoomate(int studentID, List<Integer> rankedQuestions, Boolean...trueFalseQuestions){ 
        this.studentID = studentID;
        this.rankedQuestions = rankedQuestions;
        List<Boolean> wef = Arrays.asList(trueFalseQuestions);
    }

Just make it to Boolean from boolean. 

答案 2 :(得分:0)

NewRoomate(int studentID, List<Integer> rankedQuestions, boolean...trueFalseQuestions){ 
        this.studentID = studentID;
        this.rankedQuestions = rankedQuestions;
        List<Boolean> wef = new ArrayList<Boolean>(); //initiate your list
        for(boolean question : trueFalseQuestions){ //fill your list with questions
            wef.add(question);
        }
    }