It\'s legal to do this in Java:
void spew(Appendable x) { x.append(\"Bleah!\\n\"); }
How can I do this (syntax not legal):
You could do it with generics:
public <T extends Appendable & Closeable> void spew(T t){ t.append("Bleah!\n"); if (timeToClose()) t.close(); }
Your syntax was almost right, actually.