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. golang学习之旅:方法、函数使用心得

    假设要在$GOPATH/pkg/$GOOS_$GOARCH/basepath/ProjectName/目录下开发一个名为xxx的package.(这里basepath指的是github.com/mic ...

  2. 【BZOJ-4568】幸运数字 树链剖分 + 线性基合并

    4568: [Scoi2016]幸运数字 Time Limit: 60 Sec  Memory Limit: 256 MBSubmit: 238  Solved: 113[Submit][Status ...

  3. Linux内核邮件列表发送和回复格式研究

    1.使用的内容格式为[纯文本],这个在国内的客户端已经没有了,大公司只有微软的outlook. 2.回复引用时,使用符号[>]作为标记,且回复的内容不能在最顶部,应该在最下面.参考:http:/ ...

  4. Codeforces Round #389 Div.2 E. Santa Claus and Tangerines

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  5. POJ3764 The xor-longest Path

      Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6361   Accepted: 1378 Description In ...

  6. centos7安装eclipse

    centos7安装eclipse Eclipse是一个集成开发环境(IDE),包含一个基工作区和定制环境的可扩展插件系统.大部分使用 Java 编写,Eclipse 可以用来开发应用程序.通过各种插件 ...

  7. Xpath用法

    在进行网页抓取的时候,分析定位html节点是获取抓取信息的关键,目前我用的是lxml模块(用来分析XML文档结构的,当然也能分析html结构), 利用其lxml.html的xpath对html进行分析 ...

  8. Code::Blocks快捷键操作

    编辑器 快捷键 功能 Ctrl+Z 恢复上一次操作 Ctrl+Shift+Z 重复上一次操作 F11 切换头文件/源文件 Ctrl+Shift+C 注释高亮代码 Ctrl+Shift+X 反注释高亮代 ...

  9. mysql错误

    安装mysql之后提示(ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:错误 具体就是: 安 ...

  10. codeforce B Island Puzzle

    B. Island Puzzle time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...