using Java to realize algorithms