public class JPTQuestion1 {
    public static void main(String[] args) {
        String s1 = "abc";
        String s2 = "abc";
        System.out.println("s1 == s2 is:" + s1 == s2);
    }
}

输出:false   -----------------------坑爹的是:s1 == s2 is:竟然没有输出,控制台就一个false

原因:优先级问题。syso里面是两个字符串在比较,第一个字符串是:"s1 == s2 is:" + s1, 第二个字符串是:s2,所以输出是false,而且没有s1 == s2 is:

代码片段2:

public class JPTQuestion1 {
    public static void main(String[] args) {
        String s1 = "abc";
        String s2 = "abc";
        System.out.println("s1 == s2 is:" + (s1 == s2));
    }
}

输出:s1 == s2 is:true          ---------------------真的好坑爹。

原因可以有上面的原因得出,也是优先级问题。

Java Programming Test Question 1的更多相关文章

  1. Java Programming Test Question 3

    import java.util.HashSet; public class JPTQuestion3 { public static void main(String[] args) { HashS ...

  2. Java Programming Test Question 2

    public class JPTQuestion2 { public static void main(String[] args) { String s3 = "JournalDev&qu ...

  3. Java Programming Test Question 4

    What will be the boolean flag value to reach the finally block? public class JPTQuestion4 { public s ...

  4. Java programming language compiler

    https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html\ javac - Java programming l ...

  5. Java Programming Language Enhancements

    引用:Java Programming Language Enhancements Java Programming Language Enhancements Enhancements in Jav ...

  6. 文本信息“welcome to java programming!”

    import javax.swing.JOptionPanepublic class welcome {public static void main(string[] arg){JOptionPan ...

  7. C Programming vs. Java Programming

    Thing C Java type of language function oriented object oriented basic programming unit function clas ...

  8. Difference Between Arraylist And Vector : Core Java Interview Collection Question

    Difference between Vector and Arraylist is the most common  Core Java Interview question you will co ...

  9. Java Programming Guidelines

    This appendix contains suggestions to help guide you in performing low-level program design and in w ...

随机推荐

  1. leetcode 402. Remove K Digits

    Given a non-negative integer num represented as a string, remove k digits from the number so that th ...

  2. bzoj1724: [Usaco2006 Nov]Fence Repair 切割木板

    #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> ...

  3. hdu5175 gcd 求约数

    题意:求满足条件GCD(N,M) = N XOR M的M的个数 sol:和uva那题挺像的.若gcd(a,b)=a xor b=c,则b=a-c 暴力枚举N的所有约数K,令M=NxorK,再判断gcd ...

  4. js保留位和取整

    //hold是保留位,例,元,角,分 //integerType是在保留位的基础上,如果后面有值,向上向下取整 calAmount:function(hold,integerType,amount){ ...

  5. static和public的区别

    static:静态.   可以设置:静态类.静态变量.静态方法.   没有使用static修饰的成员为实例成员. 静态成员的使用:通过类名.   1.不加static修饰的成员是对象成员,归每个对象所 ...

  6. Android中运行的错误:java.lang.UnsatisfiedLinkError: Couldn't load locSDK3: findLibrary returned null.

    ---恢复内容开始--- 明明已经加入了liblocSDK3.so,但总是无法定位.提示错误java.lang.UnsatisfiedLinkError: Couldn't load locSDK3: ...

  7. powershell小工具

    保存为.ps1文件Set-ExecutionPolicy UnrestrictedSet-ExecutionPolicy Restricted 1. 批量修改文件后缀 $CodeFileDir=&qu ...

  8. 企业应用系统设计分享PPT

    因今天上午需要为团队做一个分享,所以昨晚连夜写了一个<企业应用系统设计>的PPT,因为时间比较短,写的比较急.现在把PPT贴出来,做一个记录.同时也希望对大家有用. 文件我上传到了百度网盘 ...

  9. CSS3定位和浮动详解

    本文为大家分享CSS3定位和浮动的基础概念,与使用方法,供大家参考,具体内容如下 一.定位 1. css定位: 改变元素在页面上的位置 2. css定位机制: 普通流: 浮动: 绝对布局: 3. cs ...

  10. Java-IO之DeflaterOutputStream和InflaterOutputStream

    此类为使用 "deflate" 压缩格式压缩数据实现输出流过滤器 example import java.io.File; import java.io.FileInputStre ...