le0102
2022-03-07 16:38
采纳率: 0%
浏览 9

Bean随机抽取的问题

请问一个bean怎样随机抽取去100个放入一个新的bean呢?

public class ClassBean implements Serializable {
    private String reason;
    private List<Result> result;
    public void setReason(String reason) {
        this.reason = reason;
    }
    public String getReason() {
        return reason;
    }

    public void setResult(List<Result> result) {
        this.result = result;
    }
    public List<Result> getResult() {
        return result;
    }
    public class Result implements Serializable{

        private String id;
        private String question;
        private String answer;
        private String item1;
        private String item2;
        private String item3;
        private String item4;
        private String explains;
        private String url;
        public void setId(String id) {
            this.id = id;
        }
        public String getId() {
            return id;
        }

        public void setQuestion(String question) {
            this.question = question;
        }
        public String getQuestion() {
            return question;
        }

        public void setAnswer(String answer) {
            this.answer = answer;
        }
        public String getAnswer() {
            return answer;
        }

        public void setItem1(String item1) {
            this.item1 = item1;
        }
        public String getItem1() {
            return item1;
        }

        public void setItem2(String item2) {
            this.item2 = item2;
        }
        public String getItem2() {
            return item2;
        }

        public void setItem3(String item3) {
            this.item3 = item3;
        }
        public String getItem3() {
            return item3;
        }

        public void setItem4(String item4) {
            this.item4 = item4;
        }
        public String getItem4() {
            return item4;
        }

        public void setExplains(String explains) {
            this.explains = explains;
        }
        public String getExplains() {
            return explains;
        }

        public void setUrl(String url) {
            this.url = url;
        }
        public String getUrl() {
            return url;
        }

    }
}

例如这样的bean,我想抽取随机Result中的100个,放到一个新的bean中,请问怎样写呢? 

1条回答 默认 最新

相关推荐 更多相似问题