显示意外行为的字符串串联

  • 本文关键字:字符串 意外 显示 java
  • 更新时间 :
  • 英文 :


Bellow是我的代码片段。我只是想知道,如果条件没有被执行;ans";具有价值2020。

private static void solve() throws Exception {

String str="20";
String str1="20";
String ans=str+str1;

if(ans=="2020")
System.out.println("matched");
else System.out.println("Not matched");
System.out.println(ans);
}
ans.equals("2020")

这应该行得通。

最新更新