0

Explain the code

int i= 5, j=2; for(; i--> ++j; ); System.out.println(i+""+j);

1st May 2021, 10:03 AM
kreddyt
kreddyt - avatar
2 Réponses
+ 2
for first iteration i=4,j=3(true), second iteration i=3,j=4(false)
1st May 2021, 11:44 AM
Atul [Inactive]
+ 1
Karthik Reddy Thotamgari For first iteration (5 > 3) //true Now i = 4, j = 3 for 2nd iteration after 1st iteration For 2nd iteration (4 > 4) //false, Note :- why 4 > 4 because i++ is post increment and ++j is pre increment Iteration will stop here because of false but after 2nd iteration the value of i and j will be i = 3, j = 4
1st May 2021, 1:51 PM
A͢J
A͢J - avatar