Problem: Write a program to print 'Hello Java' on console with help of while loop
Program:Step 1 - CodingCreate a text file HelloWhile.java and copy below contents./** * A program that prints 'Hello Java' string with help of WHILE loop statements. */ public class HelloWhile { public static void main(String[] args) { int i = 0; while (i < 5) { System.out.println("Hello Java "); i++; } } } Step 2 - Deployment
Step 3 - Testing
OutputIt will print Hello five times. Hello Java Hello Java Hello Java Hello Java Hello Java FAQWhat is while loop?The while statement continually executes a block of statements
while a particular condition is true .
Its syntax can be expressed as:
Thewhile (expression) { while statement evaluates expression, which must return a
boolean value. If the expression evaluates to true , the while
statement executes the statement(s) in the while block. The while
statement continues testing the expression and executing its block until the expression
evaluates to false .<<Previous | Next>> |