+ 1

Can someone explain the program, I don't understand why the output is 326

What is the output of this code?  int x = 21; int y = 7; System.out.print(x- - /y- -); System.out.print(x+y) ; output: 326

25th Mar 2022, 3:46 AM
Eyy
5 Antworten
+ 7
first print -> 21/7 = 3 (no change in values due to post decrement operator) second print -> 20+6 = 26 (decremeted values due to previous line) output => 326 (append both values)
25th Mar 2022, 3:58 AM
Abhishek Tandon
Abhishek Tandon - avatar
+ 2
thankyouu!!! I finally understand hehehe
25th Mar 2022, 4:05 AM
Eyy
+ 1
Infinity in second print, how did it became 20 and 6? why it is not the original value?
25th Mar 2022, 4:01 AM
Eyy
+ 1
x-- in first print actually decreased the value of x and so did y-- to y
25th Mar 2022, 4:02 AM
Abhishek Tandon
Abhishek Tandon - avatar
+ 1
For clarity, post decrement operator is like - use now, decrement later
25th Mar 2022, 4:05 AM
Abhishek Tandon
Abhishek Tandon - avatar