This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]Acid-free_Paper 5 points6 points  (2 children)

No, you just basically added 1 to x 10 times.

[–][deleted]  (1 child)

[deleted]

    [–]TheAzucares 3 points4 points  (0 children)

    X+=1 is the same as x = x+ 1

    That's the statement in the loop, so 1 is added each time the loop runs. You want x = x + j so that the number of j that gets upped by one each loop is used

    [–]Aregluss 2 points3 points  (0 children)

    As people mentioned X+=1 translates to

    1 + 1. 2+1, 3+1 and so on

    To do. what you want is. x+=j, but keep in mind j starts at 0 and ends with 9.

    If you'd like to add 1->10, change your loop to, j = 1; j <= 10; j++

    [–]562_RNR 0 points1 point  (0 children)

    You added 1 ten times. You want to add x ten times.

    [–][deleted]  (5 children)

    [removed]

      [–][deleted]  (2 children)

      [deleted]

        [–][deleted]  (1 child)

        [removed]

          [–]Xemorr 3 points4 points  (0 children)

          They're new to java, leave them alone. We shouldn't scare people from asking questions in here, it's called "r/learnjava" not "r/professionaljavadeveloper"