Last active
December 28, 2015 05:09
-
-
Save hydai/7448038 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class XIII { | |
public static void main (String[] args) { | |
StringBuffer s1, s2, s3; | |
s1 = new StringBuffer("Hello"); | |
s2 = s1; | |
s1.append(" the Java master!"); | |
s3 = new StringBuffer("Hello the Java master!"); | |
// 比較法一 | |
System.out.println(s1.toString().compareTo(s2.toString()) == 0); | |
System.out.println(s1.toString().compareTo(s3.toString()) == 0); | |
System.out.println(s2.toString().compareTo(s3.toString()) == 0); | |
// 比較法二 | |
System.out.println(s1.toString().equals(s2.toString())); | |
System.out.println(s1.toString().equals(s3.toString())); | |
System.out.println(s2.toString().equals(s3.toString())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment