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. Redis哈希-hash

    Redis的hash类型数据存储极为重要 hset K V  赋值一个hash 其中V为 (key, value) 127.0.0.1:6379> hset user id 1(integer) ...

  2. epoll

    https://segmentfault.com/a/1190000003063859http://man7.org/linux/man-pages/man7/epoll.7.html EPOLLIN ...

  3. no suitable HttpMessageConverter found for request type [java.lang.Integer]

    今天在使用Spring Template的时候遇到了这个异常: no suitable HttpMessageConverter found for request type [java.lang.I ...

  4. tmux/screen里面如何用鼠标滚轮来卷动窗口内容

    tmux里面用鼠标滚轮来卷动窗口内容 在 tmux里面,因为每个窗口(tmux window)的历史内容已经被tmux接管了,所以原来console/terminal提供的Shift+PgUp/PgD ...

  5. AngularJs 脏值检查及其相关

    今天突然就想写写$digest和$apply,这些都是脏值检查的主体内容. 先以普通js来做一个简单的监控例子吧: var div = ducoment.getElementById("my ...

  6. CF 161B Discounts(贪心)

    题目链接: 传送门 Discounts time limit per test:3 second     memory limit per test:256 megabytes Description ...

  7. CentOS 6 日期 时间,时区,设置修改及时间同步

    一.时区 显示时区 date --help 获取帮助 date -R date +%z 上面两个命令都可 [root@localhost ~]# date -R; date +%z Fri, 19 O ...

  8. matlab注释

    单行注释: 两个'%': 多行注释: A. %{ 若干语句 %} B. 注释: 选中要注释的若干语句, 编辑器菜单Text->Comment, 或者快捷键Ctrl+R 取消注释: 选中要取消注释 ...

  9. wcf第1步

    添加System.ServiceModel 引用 Wcf 服务端 class Program { static void Main(string[] args) { ServiceHost host ...

  10. php实现文件上传下载功能小结

    文件的上传与下载是项目中必不可少的模块,也是php最基础的模块之一,大多数php框架中都封装了关于上传和下载的功能,不过对于原生的上传下载还是需要了解一下的.基本思路是通过form表单post方式实现 ...