JAVA practice for algorithms