I am not here to explain you eric's answer because i myself haven't understood it properly
, its too difficult man, requires around 1 hour to understand. Anyways but way below eric's answer there is Donal Fellows's answer (he too has a good reputation man) where he says eric's answer is not quite helpful
in Java. And i think the topic which you are asking is given nicely in books and that too in a bit easier manner.
Anyways someone much better and experienced person than me might help you here.