0
++ Confusion in java
++a , a++ what is difference
8 ответов
+ 8
Devashish kumar ,
here a short description:
=> *pre-increment* operator: ++x
is used to increment the value of variable `x` **before** using it in an expression.
=> *post-increment* operator: x++
is used to increment the value of variable `x` **after** executing the expression.
+ 4
++a : pre-increment
a++ : post-increment
+ 3
EXAMPLE - pre-increment
x = 5;
y = ++x; (increment x to 6, then assign 6 to y)
EXAMPLE - post-increment
a = 5;
b = a++; (assign 5 to b, then increment a to 6)
Both cases have the side-effect of incrementing and saving the variable.
Just a question whether you access the value of the variable before or after the increment happens.
+ 1
Lol
0
int a=0, b=10;
a = b++; // first a=10, then b=11
System.out.println("a="+a+", b="+ b);
a = ++b; // first b=12, then a=12
System.out.println("a="+a+", b="+ b);
0
Which app can i learn coding and programming app and others
0
Some times JavaScript is difficult
0
Sooo so difficult