While loop in Java





Similar to for Loop, while statement creates a loop that repeats until the test expression becomes false.

Syntax

intialization;
while(condition)
  { 
    body; 
    updation; 
  }                 

while Flow Diagram

prowessapps.in

Example:

WAP to print hello 5 times using while.
class WhileDemo
{
public static void main(String []arg)
 {
  int i=1;
  while(i<=5){
   System.out.print(i);
   System.out.println(". Hello");
   i++;
  }
 }
}
OUTPUT:
1. Hello
2. Hello
3. Hello
4. Hello
5. Hello

Next topic is Java-do-while-loop




 






Training For College Campus

We offers college campus training for all streams like CS, IT, ECE, Mechanical, Civil etc. on different technologies like
C, C++, Data Structure, Core Java, Advance Java, Struts Framework, Hibernate, Python, Android, Big-Data, Ebedded & Robotics etc.

Please mail your requirement at info@prowessapps.in


Projects For Students

Students can contact us for their projects on different technologies Core Java, Advance Java, Android etc.

Students can mail requirement at info@prowessapps.in



CONTACT DETAILS

info@prowessapps.in
(8AM to 10PM):

+91-8527238801 , +91-9451396824

© 2017, prowessapps.in, All rights reserved