Java Loops, Methods and Classes