The operator == is undefined for the argument type(s) int, null
来源:互联网 发布:程序员的电脑屏幕 编辑:程序博客网 时间:2024/06/07 23:16
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); }}
0 1
- The operator == is undefined for the argument type(s) int, null
- The operator || is undefined for the argument type(s) int, int
- The method setDefaultCloseOperation(int) is undefined for the type
- The method swipe(int, int, int, int, int) is undefined for the type AppiumDriver
- The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the argument
- The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the argument
- The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the argument
- The method setProgress(int, int, boolean) is undefined for the type NotificationCompat.Builder
- "The method width(int) is undefined for the type SmoothProgressDrawable.Builder"
- fragment 里需要activity。Android-The method findViewById(int) is undefined for the type first (Fragment)
- The method findViewById(int) is undefined for the type FragmentHome报错
- "The method findViewById(int) is undefined for ..."
- The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory!
- The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
- The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
- The method isEmpty() is undefined for the type String/String
- The method getJspApplicationContext(ServletContext) is undefined for the type
- The method getTextContent() is undefined for the type Node
- [zz] QuickSearchBox源码分析
- 阿里巴巴java高级工程师面试题
- const 注意点(C)
- HibernateTemplate_HibernateCallback_HibernateDaoSupport (http://blog.sina.com.cn/s/blog_8020e411010)
- 第一周项目三 时间类
- The operator == is undefined for the argument type(s) int, null
- 准备自己做块飞控,先看看方案
- Codeforces 520E Pluses everywhere (组合+逆元+规律)
- js炫酷小球沿着直线跑动导航条特效源码分享
- Android主管消息提示的Toast.makeText用法
- 第一章第三题
- mongodb 学习笔记之二 mongodb入门(数据库、文档和集合)
- 使用Condition类控制线程通信
- Apple watch 开发指南(3) 开发apple watch(翻译原创)