Java Programming Test Question 1
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的更多相关文章
- Java Programming Test Question 3
import java.util.HashSet; public class JPTQuestion3 { public static void main(String[] args) { HashS ...
- Java Programming Test Question 2
public class JPTQuestion2 { public static void main(String[] args) { String s3 = "JournalDev&qu ...
- Java Programming Test Question 4
What will be the boolean flag value to reach the finally block? public class JPTQuestion4 { public s ...
- Java programming language compiler
https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html\ javac - Java programming l ...
- Java Programming Language Enhancements
引用:Java Programming Language Enhancements Java Programming Language Enhancements Enhancements in Jav ...
- 文本信息“welcome to java programming!”
import javax.swing.JOptionPanepublic class welcome {public static void main(string[] arg){JOptionPan ...
- C Programming vs. Java Programming
Thing C Java type of language function oriented object oriented basic programming unit function clas ...
- 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 ...
- Java Programming Guidelines
This appendix contains suggestions to help guide you in performing low-level program design and in w ...
随机推荐
- mysql导入sql文件,乱码,一个例子
服务器centos,其他数据库都是utf8都正常能用 网页正常显示 这次导入一个utf8格式数据库文件 结果网页上乱码 在导出的sql文件中,注释部分有些语句也是被mysql考虑的.导出的sql文件, ...
- 【BZOJ-4561】圆的异或并 set + 扫描线
4561: [JLoi2016]圆的异或并 Time Limit: 30 Sec Memory Limit: 256 MBSubmit: 254 Solved: 118[Submit][Statu ...
- 【BZOJ-1497】最大获利 最大流
1497: [NOI2006]最大获利 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 3800 Solved: 1848[Submit][Status] ...
- jquery插件-表单验证插件-validator对象
三 Validator对象 1.介绍:Validate方法返回的对象称作Validator对象 2.使用 Validator对象常用方法 Validator.form() 返回:Boolean 验证: ...
- IIS提示“异常详细信息: System.Runtime.InteropServices.ExternalException: 无法执行程序”
先来看错误提示: 无法执行程序.所执行的命令为 "C:/Windows/Microsoft.NET/Framework/v3.5/csc.exe" /noconfig /fullp ...
- xcoj 1208 矩阵
赛场上一开始以为是递推,交了一发希望以为能卡着线过(毕竟是O(5N)的),结果WA了. 又以为是dp,最后半小时尝试各种YY...各种WA 实际上取每次transfer中最大的概率然后递推是不对的.. ...
- PHP设计模式(一)
在码PHP程序的时候,为了以后更好地维护代码和理解代码,用一些合适的设计模式是必不可少的,下面我和大家首先分享下单例模式,有错误或者不恰当的地方,还望PHPer们帮我指出. 单例模式 PHP中的对象生 ...
- POJ 2828 Buy Tickets(线段树 树状数组/单点更新)
题目链接: 传送门 Buy Tickets Time Limit: 4000MS Memory Limit: 65536K Description Railway tickets were d ...
- CF 268E Playlist(贪心)
题目链接: 传送门 Playlist time limit per test:1 second memory limit per test:256 megabytes Description ...
- HDU 4768 Flyer(二分)
题目链接: 传送门 Flyer Time Limit: 1000MS Memory Limit: 32768 K Description The new semester begins! Di ...