Computer Science, asked by dijen92, 2 months ago

How do you make the loop command in Java?is it possible or not

Answers

Answered by Oreki
7

\textsf{\textbf{Yes}, it is possible to iterate in Java.}

\textsf{\Large \textbf{Iterative constructs}}

  \text{\textbf{\large For l\symbol{111}op}}

     \text{Here, the l\symbol{111}op starts with the given value of a variable. It excetutes the}\\\text{given statement by updating the values of control variable unless the given}\\\text{condition is \textit{false}.}

     \text{\textbf{Syntax - }}

         \texttt{for (\symbol{60}initial value\symbol{62}; \symbol{60}test condition\symbol{62}; \symbol{60}update\symbol{62}) \{}\\\texttt{\hspace{2em} \symbol{92}\symbol{92} Statements to be exceuted.}\\\textt{\}}

  \text{\textbf{\large While l\symbol{111}op}}

     \text{It executes a set of statements till a given condition is \textit{true}.}

     \text{\textbf{Syntax - }}

         \texttt{while (\symbol{60}test condition\symbol{62}) \{}\\\texttt{\hspace{2em} \symbol{92}\symbol{92} Statements to be exceuted.}\\\textt{\}}

  \text{\textbf{\large Do - while l\symbol{111}op}}

     \text{Same as the while l\symbol{111}op the only difference is that it executes the a set of}\\\text{statements before the condition is checked. If the given condition is \textit{true},}\\\text{the control \symbol{114}epeats the process.}

     \text{\textbf{Syntax - }}

         \texttt{do \{}\\\texttt{\hspace{2em} \symbol{92}\symbol{92} Statements to be exceuted.}\\\textt{\}\texttt{\:\: while (\symbol{60}test condition\symbol{62});}

Similar questions