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 ...
随机推荐
- leetcode 402. Remove K Digits
Given a non-negative integer num represented as a string, remove k digits from the number so that th ...
- bzoj1724: [Usaco2006 Nov]Fence Repair 切割木板
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> ...
- 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 ...
- js保留位和取整
//hold是保留位,例,元,角,分 //integerType是在保留位的基础上,如果后面有值,向上向下取整 calAmount:function(hold,integerType,amount){ ...
- static和public的区别
static:静态. 可以设置:静态类.静态变量.静态方法. 没有使用static修饰的成员为实例成员. 静态成员的使用:通过类名. 1.不加static修饰的成员是对象成员,归每个对象所 ...
- Android中运行的错误:java.lang.UnsatisfiedLinkError: Couldn't load locSDK3: findLibrary returned null.
---恢复内容开始--- 明明已经加入了liblocSDK3.so,但总是无法定位.提示错误java.lang.UnsatisfiedLinkError: Couldn't load locSDK3: ...
- powershell小工具
保存为.ps1文件Set-ExecutionPolicy UnrestrictedSet-ExecutionPolicy Restricted 1. 批量修改文件后缀 $CodeFileDir=&qu ...
- 企业应用系统设计分享PPT
因今天上午需要为团队做一个分享,所以昨晚连夜写了一个<企业应用系统设计>的PPT,因为时间比较短,写的比较急.现在把PPT贴出来,做一个记录.同时也希望对大家有用. 文件我上传到了百度网盘 ...
- CSS3定位和浮动详解
本文为大家分享CSS3定位和浮动的基础概念,与使用方法,供大家参考,具体内容如下 一.定位 1. css定位: 改变元素在页面上的位置 2. css定位机制: 普通流: 浮动: 绝对布局: 3. cs ...
- Java-IO之DeflaterOutputStream和InflaterOutputStream
此类为使用 "deflate" 压缩格式压缩数据实现输出流过滤器 example import java.io.File; import java.io.FileInputStre ...