Can you recommend any freely available books about code golfing in general and especially in Java and C++?
There are at least two books about golfing:
"Short Coding" by Ozy (only available in Japanese I think, search for it on www.amazon.co.jp)
The Perlgolf History book, available here.
Other recommended reading:
When it comes to golfing in Java, it's not to be recommended.
Actually, I would go so far as to say (paraphrasing E. W. Dijkstra) that it cripples the mind, and therefore should be regarded as a criminal offense.
If you insist on doing codegolf in Java, all the basic stuff you need is found in java.util.Scanner (parsing input), java.math.BigInteger, and java.lang.String. In addition, the syntax for regexes and print formatting will come in handy.