Loops in Java (while, for & do...while)
class whileLoopDemo{
public static void main(String args[])
{
int i=11, n=5;
while(i<=n)
{
System.out.println(i);
i++;
}
System.out.println("Out of Loop.");
}
}
class forLoopDemo
{
public static void main(String args[])
{
int i, n=5;
for(i=6;i<=n;i++)
{
System.out.println(i);
}
System.out.println("Out of Loop.");
}
}
class doWhileLoopDemo
{
public static void main(String args[])
{
int i=11, n=5;
do
{
System.out.println(i);
i++;
}while(i<=n);
System.out.println("Out of Loop.");
}
}
Watch Video of Practical Explanation
No comments
Post your comments