In this example, We will discuss about the implementation of while loop in java programming.
while loop in Java
In this example, We will discuss about the implementation of while loop in java programming. Loop repeats a statement or a process multiple times according to the specified conditions. While loop checks the certain condition first, if the condition is true then all the statements or processes written under the while loop are executed otherwise ignored all.
Example: WhileExample.java
package com.devmanuals2; import java.io.*; public class WhileExample { public static void main(String[] args) throws IOException { System.out.println("Enter any number"); BufferedReader buffread = new BufferedReader(new InputStreamReader( System.in)); String str = buffread.readLine(); Integer ch = Integer.parseInt(str); System.out.println("The table of " + ch + " is= "); int i = 1; while (i <= 10) { int t = ch * i; System.out.println(t); i++; } } }
Output:
Enter any number 25 The table of 25 is = 25 50 75 100 125 150 175 200 225 250 |
[ 0 ] Comments