`
love422619
  • 浏览: 17478 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Long equal(Long)

阅读更多

 昨天突然发现!两个都是Long类型的变量比较,出现了思想误区!
例如: 
    Long a=Long.valueOf(4);
    Long b=Long.valueOf(5);
    boolean c=(a==b);
    boolean d=a.equals(b);
结果c为true,d为false;
因为Long是封装类,属于对象,比较应该用equlas而不是用==,然而long是基本数据类型,是可以用==比较的! 

分享到:
评论

相关推荐

    细数java中Long与Integer比较容易犯的错误总结.docx

    boolean isEqual = a.longValue() == b.longValue(); ``` 3. **了解缓存机制**: 了解`Long`和`Integer`的缓存机制可以帮助避免不必要的对象创建,提高性能。 #### 五、总结 在Java开发中,正确地比较`Long`和`...

    贝叶斯判别程序

    (TrnX1, TrnX2, rate=1, TstX = NULL, var.equal = FALSE){ if (is.null(TstX) == TRUE) TstX(TrnX1,TrnX2) if (is.vector(TstX) == TRUE) TstX(as.matrix(TstX)) else if (is.matrix(TstX) != TRUE) TstX(TstX...

    EE19 Geometries.docx

    2. **比较几何对象**:`Algorithms.IsEqual(geometry)` - 比较两个几何对象是否相等。 #### 七、测量几何对象 几何对象可以用来计算以下几何属性: 1. **长度**:`geometry.length` - 计算线性几何对象的长度。 2...

    3_HeartToHeart_biofeedback_skinconductance_VO2_

    This study aimed to examine whether athletic performances improves by reducing running time using HRV BFB in long distance runners.Methods: 24 track athletes were randomly divided into two equal ...

    经典的DSP的C程序和汇编程序库

    /* IS EQUAL TO THAT OF UNSCALED H(S) AT WSCL RAD/SEC */ /* IERROR=0 NO ERRORS DETECTED */ /* 1 INVALID FILTER ORDER (L<=0 OR L>=LN) */ /* 2 INVALID SCALE PARAMETER (WSCL) */ #ifndef KR void spbssl...

    SpringBoot根据id分页查询.zip

    criteriaBuilder.equal(root.get("id"), id), pageable); } } ``` 在上面的代码中,我们使用了JPA的Criteria API进行动态查询,根据传入的ID筛选出符合条件的用户,并结合`Pageable`返回分页结果。 如果项目中...

    Color Appearance Models, Second Edition

    For as long as human scientific inquiry has been recorded, the nature of color perception has been a topic of great interest. Despite tremendous evolution of technology, fundamental issues of color ...

    Design of tunable metal-coated long-period fiber grating filter with dispersion consideration

    The design of a tunable metal-coated long-period fiber grating (LPFG) filter based on the material dispersion consideration is presented. The tuning of the resonant wavelength can be achieved by ...

    必修1Unit1录音Grammar.ppt

    例如,当直接引语是陈述句时,如:“I have a long body and long arms, a gift and love for swimming.” 转换成间接引语时,我们会使用 "that" 引导的宾语从句,同时人称和时态可能发生变化,如:“Phelps said he...

    Dijkstra 算法原理

    SAME_RANGE_NODE rangeNode = mmapWaypoint.equal_range(rkey); for (CRWPIT it=rangeNode.first; it!=rangeNode.second; it++) { i++; Node* pn = it->second; vec.push_back(pn); } return i; } ...

    8051助记符/地址对照表

    CJNE - Compare and Jump if Not Equal CLR - Clear Register CPL - Complement Register DA - Decimal Adjust DEC - Decrement Register DIV - Divide Accumulator by B DJNZ - Decrement Register and Jump if Not...

    C++ flaot处理

    std::cout << "a and b are approximately equal"; } ``` 四、格式化输出 在C++中,可以使用`std::cout`配合`std::setprecision`和`std::fixed`控制台流操纵符来控制浮点数的输出格式。例如,要输出保留两位小数的...

    Jakarta Commons CookBook学习笔记

    long[] primitiveArray = new long[]{12, 100, 2929, 3323}; Long[] objectArray = ArrayUtils.toObject(primitiveArray); Double[] doubleObjects = new Double[]{new Double(3.22), new Double(3.22)}; ...

    博士研究生英语精读-翻译与原文(中科院).doc

    While the digital age has made vast amounts of knowledge available to the masses, the sheer volume can be overwhelming, and not all individuals have equal access or the skills to navigate this ...

    java8看不到源码-ktime:kotlin对java8时间库的扩展

    Long和Double值可以后缀一个时间单位来创建一个Duration val delay = 30.seconds // equal to Duration.ofSeconds(30) val longDelay = 2.5.minutes // equal to Duration.ofSeconds(150) 可用Duration后缀: nanos ...

    Androd时间戳转化

    // both timestamps are equal } ``` 总结,Android开发中的时间处理涉及时间戳的转换、日期的格式化以及时间的比较。理解这些概念和方法对于开发涉及时间处理的应用至关重要。在实际项目中,你可以根据需求选择...

    一维数组实验报告.docx

    long getPrefix(long number, int k); int main() { long cardNumber; printf("请输入信用卡号: "); scanf("%ld", &cardNumber); if (isValid(cardNumber)) { printf("信用卡号合法\n"); } else { printf(...

    jpa的一对多和多对多代码

    criteria.where(builder.equal(root.get("parent"), parentEntity)); List<ChildEntity> children = entityManager.createQuery(criteria).getResultList(); ``` 通过上述代码,我们可以看到JPA如何优雅地处理一对...

    D_JPA_02_简单实体映射和API.zip

    cq.where(cb.equal(root.get("name"), "张三")); List<User> users = entityManager.createQuery(cq).getResultList(); ``` 这个压缩包可能包含了上述概念的实例代码,通过阅读和运行这些代码,你可以更好地理解...

Global site tag (gtag.js) - Google Analytics