0

++ Confusion in java

++a , a++ what is difference

12th Feb 2025, 7:22 PM
Devashish kumar
Devashish kumar - avatar
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.
12th Feb 2025, 7:47 PM
Lothar
Lothar - avatar
+ 4
++a : pre-increment a++ : post-increment
12th Feb 2025, 7:39 PM
Mihaly Nyilas
Mihaly Nyilas - avatar
M
+ 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.
13th Feb 2025, 3:55 AM
Shardis Wolfe
+ 1
Lol
14th Feb 2025, 6:19 PM
𝓗𝓮𝓻 𝓚𝓲𝓷𝓰 🤍
𝓗𝓮𝓻 𝓚𝓲𝓷𝓰 🤍 - avatar
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);
13th Feb 2025, 6:57 PM
zemiak
0
Which app can i learn coding and programming app and others
14th Feb 2025, 6:13 PM
Ferb Ugochukwu
0
Some times JavaScript is difficult
14th Feb 2025, 6:13 PM
Ferb Ugochukwu
0
Sooo so difficult
14th Feb 2025, 6:13 PM
Ferb Ugochukwu