list<E>泛型的问题

来源:互联网 发布:程序员招聘信息 编辑:程序博客网 时间:2024/06/17 07:07
    @Transactionalpublic int addQuestions(Map<String, Object> map, List<Integer> njsIds) {        QuestionsNjs questionsNjs = new QuestionsNjs();Questions q = new Questions();try {BeanUtils.copyProperties(q, map);} catch (IllegalAccessException e) {e.printStackTrace();} catch (InvocationTargetException e) {e.printStackTrace();}questionsDao.insert(q);int userId = q.getUserId();int questionId = q.getId();questionsNjs.setQuestionId(questionId);questionsNjs.setStateForNjs(StateConstants.QuestionStateForNjs.PENDING.v());for (Integer i : njsIds) {questionsNjs.setNjsId(i);//问题农技师关联表新增记录questionsNjsDao.insert(questionsNjs);//给每个农技师一条消息addOneMessage(StateConstants.MessageType.QAMSG.v(),"tag",userId);}return 0;}

这行报错for (Integer i : njsIds)  String不能转成Integer
这是因为第一行的  List<Integer> njsIds) 不行,是个编译时的泛型,发现不了,运行时就不会报错,会在下面报错
0 0
原创粉丝点击