Java Loop, Methods and Classes