gpt4 book ai didi

java - Java 中的字符串比较...?

转载 作者:行者123 更新时间:2023-11-29 09:35:10 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How do I compare strings in Java?

为什么第一次比较 ( s1 == s2 ) 显示相等,而第二次比较 ( s1 == s3 ) 显示不相等....?

    public class StringComparison
{

public static void main( String [] args)
{
String s1 = "Arsalan";
String s2 = "Arsalan";

String s3 = new String ("Arsalan");

if ( s1 == s2 )
System.out.println (" S1 and S2 Both are equal...");
else
System.out.println ("S1 and S2 not equal");

if ( s1 == s3 )
System.out.println (" S1 and S3 Both are equal...");
else
System.out.println (" S1 and S3 are not equal");

}
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com