first java algorithm practice