fork download
  1. class Program
  2. {
  3. public static void main (String[] args)
  4. {
  5. /* Test 1 */
  6. String s1 = "String";
  7. String s2 = "String";
  8. System.out.println("Test 1:");
  9. System.out.println(s1==s2);
  10. System.out.println(s1.equals(s2));
  11. /* Test 2 */
  12. String s3 = new String("String");
  13. String s4 = new String("String");
  14. System.out.println("Test 2:");
  15. System.out.println(s3==s4);
  16. System.out.println(s3.equals(s4));
  17. /* Test 3 */
  18. String s5 = s1;
  19. String s6 = s1;
  20. System.out.println("Test 3:");
  21. System.out.println(s5==s6);
  22. System.out.println(s5.equals(s6));
  23. /* Test 4 */
  24. String s7 = s1;
  25. String s8 = s2;
  26. System.out.println("Test 4:");
  27. System.out.println(s7==s8);
  28. System.out.println(s7.equals(s8));
  29. /* Test 5 */
  30. String s9 = s3;
  31. String s10 = s4;
  32. System.out.println("Test 5:");
  33. System.out.println(s9==s10);
  34. System.out.println(s9.equals(s10));
  35. }
  36. }
Success #stdin #stdout 0.09s 320512KB
stdin
Standard input is empty
stdout
Test 1:
true
true
Test 2:
false
true
Test 3:
true
true
Test 4:
true
true
Test 5:
false
true