The operator == is undefined for the argument type(s) int, null
package cn.edu.shu.web.test;
public class TestInteger {
public static void main(String[] args) {
/**
* 很奇怪的问题,问题来源是在Struts2的action中,假设从session中取值,假设取不到的话,那么应该为null,因为我将其强转为Integer类型了,其后再将其与Integer比較时,竟然抛空指针异常
*/
Object one = null;
Integer two = (Integer) one;
System.out.println(null == two);// out put true
System.out.println(two instanceof Integer);// out put false
System.out.println(two instanceof Object);// out put false
// System.out.println(0 == two);// 抛出空指针异常
// 思索,因为JDK有自己主动拆装箱操作,所以即使用的是Integer,其也会被拆箱为int类型,这样在使用==操作符时,不满足int型和null型比較
// 编译错误: The operator == is undefined for the argument type(s) int, null
System.out.println(0 == null);
}
}
The operator == is undefined for the argument type(s) int, null的更多相关文章
- java 短路与(||)时报错The operator || is undefined for the argument type(s) int, boolean
今天在使用短路与时,报错The operator || is undefined for the argument type(s) int, boolean 代码如下: 最后发现是少了一个=,比较要使 ...
- 项目重新部署后报The attribute required is undefined for the annotation type XmlElementRef
在另外一台机器上部署项目,项目导进Eclipse中发现有异常 public class BooleanFeatureType extends FeatureBaseType{ @XmlElementR ...
- Caused by: java.lang.IllegalArgumentException: argument type mismatch
下面是我的报错信息 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java: ...
- @RequestParam注解使用:Name for argument type [java.lang.String] not available, and parameter name information not found in class file either.
详细错误信息 Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Re ...
- struts上传文件报argument type mismatch错误
报错如下图所示: 报错原因:把String 强行转换成FormFile,所以才会抛出argument type mismatch.经查询:表单(html:form)中enctype="mul ...
- The attribute required is undefined for the annotation type XmlElementRef
异常描述: 几天没用的项目导进Eclipse中发现有异常 public class BooleanFeatureType extends FeatureBaseType{ @XmlElementRef ...
- Python pika, TypeError: exchange_declare() got an unexpected keyword argument 'type' 问题修复
网上很多写法都是 type='fanout' 这样的.(这里是基于python=3.6版本, pika=0.13.0 版本) credentials = pika.PlainCredentials(' ...
- 关于spring java.lang.IllegalArgumentException: Name for argument type [java.lang.String] 的错误
况描述: web工程在windows环境eclipse下编译部署没有问题,系统升级时需要运维从Git取相应的源码并编译部署到线上机器,部署启动正常没有错误,当访问业务的action时报错,如下. 错误 ...
- 【Problems】Could not set property 'id' of 'xxx' with value '' Cause argument type mismatch
一个问题:向comment表添加记录时,报错, 无法设置值. reflection.ReflectionException: Could not set property 'id' of 'class ...
随机推荐
- Base64编码 概念和用途
Base64概念 什么是Base64? 依照RFC2045的定义,Base64被定义为:Base64内容传送编码被设计用来把随意序列的8位字节描写叙述为一种不易被人直接识别的形式.(The Base6 ...
- [WebGL入门]四,渲染准备
注意:文章翻译http://wgld.org/,原作者杉本雅広(doxas),文章中假设有我的额外说明,我会加上[lufy:].另外.鄙人webgl研究还不够深入,一些专业词语,假设翻译有误,欢迎大家 ...
- cocos2d-x3.0 windows 环境配置
cocos2d-x3.0 windows 环境配置 参考Oo泡泡糖oO的CSDN博文 :http://blog.csdn.net/u010296979/article/details/24273393 ...
- Android SDCard Mount 流程分析
前段时间对Android 的SDCard unmount 流程进行了几篇简短的分析,由于当时只是纸上谈兵,没有实际上的跟进,可能会有一些误导人或者小错误.今天重新梳理了头绪,针对mount的流程再重新 ...
- Unity3D游戏开发最佳实践20技能(两)
[扩展和MonoBehaviourBase] 21.扩展一个自己的Mono Behaviour基类.然后自己的全部组件都从它派生 这能够使你方便的实现一些通用函数.比如类型安全的Invoke.或者是一 ...
- 【智能家居篇】wifi网络访问原理(下一个)——联想Association
转载请注明出处:http://blog.csdn.net/Righthek 谢谢! 认证完毕后,下一步就是关联(Association). 工作站与基站进行关联.以便获得网络的全然訪问权. 关联属于一 ...
- SettingsProvider 它SettingsCache
转载请注明出处:http://blog.csdn.net/droyon/article/details/35558437 SettingsCache,如指出,SettingsProvider缓冲.这将 ...
- java一般使用基础
1.这是一个通用 仿制药javaA型安全机制来保护. 它是通过变量的类型,如果,实现变量类型限制,从而保证了程序编译变量类型的安全性在一定程度上.反之.如果没有泛型,这些只存在于程序,如果猿的大脑,这 ...
- PYTHON单元测试
PYTHON开发入门与实战11-单元测试 1. 单元测试 本章节我们来讲讲django工程中如何实现单元测试,单元测试如何编写以及在可持续项目中单元测试的重要性. 下面是单元测试的定义: 单元测试是开 ...
- javascript/jquery读取和修改HTTP headers
javascript/jquery读取和修改HTTP headers jquery修改HTTP headers jQuery Ajax可以通过headers或beforeSend修改request的H ...