1.

Write the code given below using ‘for’ loop instead of ‘while’ loop :int i = 1 ;while (i <= 5) {if (i *i = = 4)jTextFieldl. setText(" " + i) ; i = i + 1 ;}

Answer»

The given code using ‘for’ loop instead of ‘while’ loop :

int i

for (i = 1 ; i < = 5 ; i + +)

{

if (1 * i = = 4)

jTextFieldl. setText ( “ “ + i) ; 

}



Discussion

No Comment Found

Related InterviewSolutions