Hi.

I put it all in a java file called A.java and it works as expected?

What IDE / Development environment are you using?

Best regards
Ewald