Recursive programs in Java