0

why output is 35 i guess it should be 34 once visit my code

public class Program { public static void main(String[] args) { int x = 34; int y = x++; System.out.println(x); } }// my ans is 35

4th May 2020, 5:03 PM
Sudip Giri
Sudip Giri - avatar
2 Respuestas
+ 1
because incremental operation modifie always the initial variable
4th May 2020, 5:19 PM
HEUBA BATOMEN Franck Duval
HEUBA BATOMEN Franck Duval - avatar
0
This is called post increment. The value is first assigned and then incremented. Print y and it will give 34 where as x has become 35.
4th May 2020, 6:38 PM
Avinesh
Avinesh - avatar