+ 1

Can anyone explain me this code?

int a = 5; int b = 3; System.out.print(a++ + b++); System.out.print(a + 1 + b); System.out.print(--a + --b); output: 8118

17th Mar 2019, 12:23 PM
Purvesh Pawar
Purvesh Pawar - avatar
2 Antworten
+ 6
// You use the increment and decrement in the code. https://www.sololearn.com/learn/Java/2141/?ref=app
17th Mar 2019, 12:32 PM
program
program - avatar
+ 8
SL have a Code playground to practice, Try to use the println() method and you will see the result for each line of code, with the print() method you get the result in one line! Pay attention to using increment: ++, and decrement: --, operators. The prefix and postfix increment both increase the value of a number by 1. The only difference between the two is their return value. The former increments (++) first, then returns the value of x, thus ++x. The latter returns the value of x first, then increments (++), thus x++.
17th Mar 2019, 12:49 PM
Danijel Ivanović
Danijel Ivanović - avatar