Skip to content

Instantly share code, notes, and snippets.

@frsyuki
Created September 16, 2011 16:43
Show Gist options
  • Save frsyuki/1222514 to your computer and use it in GitHub Desktop.
Save frsyuki/1222514 to your computer and use it in GitHub Desktop.
import java.io.InputStream;
public class X {
public static void main(String[] args) {
new X().write(null);
// ^
// X.java:5: reference to write is ambiguous, both method write(java.lang.String) in X and method write(java.io.InputStream) in X match
}
public void write(Object o) {
System.out.println("Object");
}
public void write(String o) {
System.out.println("String");
}
public void write(InputStream o) {
System.out.println("InputStream");
}
}
public class Y {
public static void main(String[] args) {
new Y().write(null);
// => "String"
}
public void write(Object o) {
System.out.println("Object");
}
public void write(String o) {
System.out.println("String");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment