You learn something new everyday as a programmer. Whilst reading a preview of The Well-Grounded Java Developer 2nd Edition (MEAP V02), I noticed something that looks like duck typing!
var duck = new Object() {
void quack() {
out.println("Quack!");
}
};
duck.quack();
// output
Quack!
This is referred to as a non-denotable type, it is inferred as the type of the expression that is assigned. In this case, the type is effectively Object but extended with a method called quack().
Currently our duck variable can only be used in the local method, but perhaps this is a sign of more dynamic programming features to come? Interesting times.