efaculty.in efaculty.in
  • Home
  • Java
  • Java Programs
  • C Language
  • C Programs
  • How to
  • Contact
  • Java

  • About Java
  • Java History
  • Java Features
  • First program in Java
  • Java Data Types
  • Java Keywords
  • Java Variables
  • Java Operators
  • Java Type Casting or Type Conversion
  • Java Comments
  • Java if else
  • Java switch
  • Java while
  • Java do while
  • Java for
  • Java break and continue
  • ---
  1. Home
  2. Java
  3. Java while

Java while

What is Loops?

When we want to execute a block execute multiple time then we use loop.It executes until condition is true.

The while executes a block of code as long as a given condition is true.

while (condition) {
  // code block to be executed
}

Sample program with if
Write a program or WAP to print 1 to 10 using while loop.

class SampleSwitch
{
   public static void main(String args[])
   {
        int num= 4;
	while (num <= 10) {
	  System.out.println(num);
	  num++;
	}
   }
}

Output:

1
2
3
4
5
6
7
8
9
10

Find us

www.efaculty.in

India

+91-9454163745

efaculty.in[@]gmail.com

Recent Pages
  • All AKTU Affiliated Colleges List
  • Language Codes
  • Country Codes
  • Pin Codes or Postal Codes of India
Most recent posts
  • Remove Background
  • Shadows & Mirror Reflection
  • Logo Design
  • Vectorization
  • Hair Masking/Clipping
Follow us
  • efaculty

  • https://www.twitter.com/

  • https://www.lipsum.com/

  • Home
  • Computer Basic
  • C Language
  • JAVA
  • About Us
  • Contact Us

Copyright @2019 | Designed by Afaq Ahmad Khan