关于 Type mismatch: cannot convert from Integer to int
2016-10-15 22:06
561 查看
Integer count=1;
会报Type mismatch: cannot convert from int to Integer。
这是因为我用的jdk是1.8版本的,编译器 用的1.6版本编译,myeclipse6.5,没有1.7版本的编译器可以选择了,我又不想重装myeclipse,因为太麻烦了。所有我就用用自己的方式去解决了问题。
HttpSession session=request.getSession();
System.out.println("sessionId:"+session.getId());
Integer count= (Integer) session.getAttribute("count");
if(count==null){
count=new Integer(1); // Integer count=0
}else{
count=new Integer(count.intValue()+1);
}
session.setAttribute("count", count);
会报Type mismatch: cannot convert from int to Integer。
这是因为我用的jdk是1.8版本的,编译器 用的1.6版本编译,myeclipse6.5,没有1.7版本的编译器可以选择了,我又不想重装myeclipse,因为太麻烦了。所有我就用用自己的方式去解决了问题。
HttpSession session=request.getSession();
System.out.println("sessionId:"+session.getId());
Integer count= (Integer) session.getAttribute("count");
if(count==null){
count=new Integer(1); // Integer count=0
}else{
count=new Integer(count.intValue()+1);
}
session.setAttribute("count", count);
相关文章推荐
- Type mismatch: cannot convert from Integer to int(java 报错)
- Type mismatch: cannot convert from Enumeration<String> to Enumeration<Object>
- Hibernate Type mismatch: cannot convert from CascadeType to CascadeType[]
- 使用Junit出现Type mismatch: cannot convert from Test to Annotation
- 使用Junit出现Type mismatch: cannot convert from Test to Annotation
- Id Type mismatch: cannot convert from connection to connection
- Type mismatch: cannot convert from Test to Annotation
- Type mismatch: cannot convert from Test to Annotation
- 由"Type mismatch: cannot convert from View to ProgressBar"联想到的类型转换错误的根源
- 报错信息:Type mismatch: cannot convert from org.hibernate.Transaction to javax.transaction.Transaction
- Type mismatch: cannot convert from Object to String
- Type mismatch: cannot convert from Test to Annotation
- Jdbc-Type mismatch: cannot convert from java.sql.ResultSet to com.mysql.jdbc.ResultSet
- Type mismatch: cannot convert from java.sql.Connection to com.sun.。。。问题的解决
- Type mismatch: cannot convert from MainFragment to Fragment 报错
- Type mismatch: cannot convert from Test to Annotation
- Type mismatch: cannot convert from java.sql.PreparedStatement to com.mysql.jdbc.PreparedStatement
- Type mismatch: cannot convert from MainFragment to Fragment 报错
- Type mismatch: cannot convert from org.hibernate.annotations.CascadeType to javax.persistence.Cascad
- Type mismatch: cannot convert from Object to Member