+ 1

explain the output of java code

int x = 5; System.out.println((i++)+(++i));

16th Mar 2020, 3:54 PM
Anil Kumar V V S S
Anil Kumar V V S S - avatar
3 Answers
+ 3
Here i++ will be 5 before incrementing by 1 here ++i will be 7 because after doing operation on i++ , i will be 6 so ++i will be 7 So finally 5 + 7 = 12
16th Mar 2020, 4:11 PM
A͢J
A͢J - avatar
+ 1
🦋FEATHER🦋 i++ first assign the value then increment i by 1 and ++i first increment value by 1 then assign so here should be 5 + 7 = 12;
16th Mar 2020, 5:06 PM
A͢J
A͢J - avatar
0
++ means increment of 1 There for technically it's like: System.out.println((6)+(6)); Therefore output : 12
16th Mar 2020, 4:49 PM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar