今天在开发中判断两个Integer值相等,

Integer a = 3;

Duixiang duixiang = new Duixiang();

duixiang = DAO.getDuixiang();

Integer b = duixiang.getB();

System.out.print(a == b);
System.out.print(a.equals(b));

发现a==b时,为false,a.equals(b)为true。

后来发现因为我b的值是从数据中拿出的一个对象的值。a和b的id不相同,所以导致了a==b为false。

得出的结论,Integer为对象,如果判断相等要用equals,而不能用==。

如果是判断两个int值相等,则可以用==;

判断Integer值相等最好不用==(未整理)的更多相关文章

  1. [Java]判断Integer值相等最好不用==最好使用equals

    测试代码 Integer c = ; Integer d = ; Integer e = ; Integer f = ; System.out.println(c == d); System.out. ...

  2. 判断Integer值相等最好不用==最好使用equals

    Integer c = 3;Integer d = 3;Integer e = 321;Integer f = 321;System.out.println(c == d);System.out.pr ...

  3. 判断Integer值相等不能用==

    今天在开发中判断两个Integer值相等, Integer a = 3; Duixiang duixiang = new Duixiang(); duixiang = DAO.getDuixiang( ...

  4. Integer值判断是否相等问题

    昨天在开发中遇到一个问题,定义了两个Integer变量,暂且定义为Integer a;  Integer b; 这两个值由前端赋值并传到后台,前台传的是a = 12345, b = 12345,  但 ...

  5. 问题-MyBatis不识别Integer值为0的数据

    问题-MyBatis不识别Integer值为0的数据 问题:使用MyBatis的过程中,发现一个值为0的数据,Mybatis所识别,最后定位才发现,是自己的写法有问题, <if test=&qu ...

  6. HTML、CSS、JS 样式 (未整理)

    随手记,有错误的地方希望留言 ^.-.^ PHP 实现关闭浏览器窗口echo "<script>window.close();</script>"; jqu ...

  7. if判断和switch case 和三元运算符整理

    if判断和switch case 和三元运算符整理 例子1:if判断写法: <script type="text/javascript"> var num = 12; ...

  8. SQL3120W 不能将xx的字段值转换成 INTEGER值

    一次用DB2 Load/Import导入数据时,报错,提示SQL3120W 不能将xx的字段值转换成 INTEGER值,但目标列不可为空.未装入该行. 目标表: CREATE TABLE TEST( ...

  9. 使用页面Tag判断某个值为空值时,不能使用logic:equal(无效),可以使用logic:notPresent

    使用页面Tag判断某个值为空值时,不能使用logic:equal(无效),可以使用logic:notPresent

随机推荐

  1. 使用bootstrap和metroui设计的微网站或手机app界面

    今天使用bootstrap和metroui设计了一个metro风格的移动app或者微信微网站的界面 程序的源代码可以从此处获得:https://github.com/mz121star/weixin- ...

  2. NuGet学习笔记(转)

    NuGet学习笔记(1)——初识NuGet及快速安装使用 http://kb.cnblogs.com/page/143190/ 1. NuGet是什么? NuGet is a Visual Studi ...

  3. 用ASP.NET Core 1.0中实现邮件发送功能

    准备将一些项目迁移到 asp.net core 先从封装类库入手,在遇到邮件发送类时发现在 asp.net core 1.0中并示提供SMTP相关类库,于是网上一搜发现了MailKit 好东西一定要试 ...

  4. UnionPay,ChinaPay 最新 银联支付接口C#\Asp.net\MVC 版本

    1.概念普及 一.理解什么是UnionPay.ChinaPay 这两个概念如果搞不清楚,绝对够你瞎折腾一段时间的. UnionPay:中国银联,最大的机构:他本身也提供系统接口但都是B2B的,对于单个 ...

  5. android studio出现Error:compileSdkVersion android-x requires compiling with JDK 7问题

    初装Android studio的童鞋可能或多或少会存在一些问题,比如出现Error:compileSdkVersion android-x requires compiling with JDK 7 ...

  6. 百度地图API 关键字模糊搜索

    http://api.map.baidu.com/place/v2/search?q=广场&region=汕头&output=json&ak=5E56A48675a5cd09a ...

  7. SQL Server 数据库操作类

    /// <summary> /// SQLServerHelper的摘要说明. /// </summary> public class SQLServerHelper { pu ...

  8. android 编译 release 签名

    1.编译 ionic build --release android 2.签名文件 keytool -genkey -alias kwwy -keyalg RSA -validity 40000 -k ...

  9. Win7“当前用户没有安装Microsoft Office"

    故障:在win7 win10系统已安装office2007~但打开word excel应用程序时提示"当前用户没有安装Microsoft Office". 原因:office200 ...

  10. IIS7/IIS7.5 二级域名伪静态设置方法

    转载地址:http://www.admin5.com/article/20120107/402582.shtml