R and JAVA excersice