Skip to content

Instantly share code, notes, and snippets.

@ucheng
Created January 21, 2013 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ucheng/4585297 to your computer and use it in GitHub Desktop.
Save ucheng/4585297 to your computer and use it in GitHub Desktop.
public class StringEquals {
public static void main(String[] args) {
jack();
jill();
jeff();
john();
}
public static void jack() {
String s1 = "hill5";
String s2 = "hill" + "5";
System.out.println(s1 == s2);
}
public static void jill() {
String s1 = "hill5";
String s2 = "hill" + s1.length();
System.out.println(s1 == s2);
}
public static void jeff() {
String s1 = "hill5";
int i = 5;
String s2 = "hill" + i;
System.out.println(s1 == s2);
}
public static void john() {
String s1 = "hill5";
String s2 = "hill" + 5;
System.out.println(s1 == s2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment