You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MethodsWithTheSameName.java 700B

1234567891011121314151617181920212223242526
  1. import org.aspectj.testing.Tester;
  2. public class MethodsWithTheSameName {
  3. public static void main(String[] args) {
  4. Inner i = new Inner("inner");
  5. i.f((String)null);
  6. i.f("call1");
  7. i.f(new Inner("call2"));
  8. Tester.checkEqual(strings, "null:inner-null:null-inner:null:call2:");
  9. }
  10. static String strings = "";
  11. static class Inner {
  12. String s;
  13. Inner(String s) { this.s = s; }
  14. void f(String str) {
  15. f(str == null ? null : new Inner("null-"+s));
  16. f(str == null ? new Inner(s+"-null") : null);
  17. }
  18. void f(Inner i) { strings += i + ":"; }
  19. public String toString() { return s; }
  20. }
  21. }