java code for algorithm study