我想将对象转换为短。我的代码是这样的:
List<Batch> lsMaxBatch = em.createNativeQuery(sqlMaxBatch).getResultList();
Iterator iter = lsMaxBatch.iterator();
while (iter.hasNext()) {
Short batchId = Short.valueOf(iter.next() + "");
ls.add(batchId);
}
可以吗?
因为如果我这样做转换:
Short batchId = (Short) iter.next();
我收到一个错误:
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.Short
谢谢