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 ...
随机推荐
- JSP简单的练习-功能标签
<!-- userfn.jsp --> <%@ page contentType="text/html;charset=gb2312" %> <%@ ...
- Asp.NET MVC3 使用 SignalR 实现推
一,简单介绍 Signal 是微软支持的一个执行在 Dot NET 平台上的 html websocket 框架. 它出现的主要目的是实现server主动推送(Push)消息到client页面,这样c ...
- 记录我第一次在Android开发图像处理算法的经历
大概是四月底的时候.有人加我QQ问我是否做能做一些基于图像皮肤检測的算法, 主要是实现对皮肤六项指标: 1. 水分 2. 有份 3. 痤疮与痘痘 4. 色斑与肤 ...
- android在当前app该文件下创建一个文件夹
/********************************************************************* * Author : Samson * Date ...
- PHP MVC自己主动RBAC自己主动生成的访问路由
使用的关键点: ReflectionClass class Rbac extends MY_Controller { public function index() { $arr = glob( __ ...
- CentOS 7 / RHEL 7 上安装 LAMP + phpMyAdmin
原文 CentOS 7 / RHEL 7 上安装 LAMP + phpMyAdmin 发表于 2014-11-02 作者 Haoxian Zeng 更新于 2014-12-12 之前根据在 Lin ...
- C++ Web Programming
一般的网关接口或者CGI,就是一个标准的集合.它定义信息怎样再问吧server和一般脚本间的交换. CGI的说明书是由NCSA维护,NCSA定义CGI的范畴:一般的网关接口或者CGI是外部网关程序的一 ...
- Java日期的格式String类型GMT,GST换算成日期Date种类
请尊重他人的劳动成果.转载请注明出处:Java日期格式化之将String类型的GMT,GST日期转换成Date类型 http://blog.csdn.net/fengyuzhengfan/articl ...
- Ubuntu下怎样切换到ROOT登录
原文:http://james23dier.iteye.com/blog/721246 近期一直在学习linux,选择ubuntu作为联系的操作系统.然后一直发现自己所创建的用户和root用户不是一个 ...
- NYOJ 330 一个简单的数学
一个简单的数学题 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描写叙述 zyc近期迷上了数学,一天,dj想出了一道数学题来难住他.算出1/n,但zyc一时答不上来希望大家能 ...