Added solution to exercise 4.3 in java