+ 6
What to do to increment by 2 instead of 1 ?
public class Program { public static void main(String[] args) { int test = 5; ++ test; System.out.println(test); } } what should I do to get the output 7 instead of 6?
8 Antworten
+ 23
you can replace ++test; with
test+=2; it will do the job done for you
+ 11
use
++test ;
++test;
OR
test + = 2;
OR
test = test + 2;
that your choice Now
+ 10
You have written ++test. Here ++operator increments the value of test by 1 .You can also write like this test += 1; it means test = test+1; For incrementing the value of test by 2,3 or by any number you just need to write how much times you want to increment it . For 2 you should write test+=2.
+ 5
for doing so remove the line ++ test and in place of it place test =test+2; or test+=2;
+ 2
you can use ++ + ++ pre increment by 2
num=num+2
+ 2
int test = 5;
text += 2;
Print out test it will give u 7
+ 2
Use test+=2;
Or the number of steps instead of 2
+ 1
another cool way: use ++++test;