Write a program to Print 1 to 100 using the Continue Jump Statement

Share Your Love

Hello guys, welcome to lingarajtechhub.com . Today we are going to discuss print 1 to 100 using the continue jump statement.

Code:

package com.continue.java;
  public class Jump_Statement {
    public static void main(String[] args) {
     int i;
     for(i=1;i<=100;i++)
     {
       if(i==50) {
            System.out.println("Now continue Hit");
       continue;
     }
   System.out.println(i);
  }
 }
}

Line-1:

package com.continue.java;
It is a java package , this package is created in a java project and it contains classes inside the package.

Line-2:
public class Jump_Statement
Here ” Jump_Statement ” is the class-name , class is a template used to create objects & class-name first letters must be capitalized . It is public means we can access this data in another project.

Line-3:

public static void main(String[] args)
It is the main method in which we can execute a program.
● public : It is an access modifier. The main() is public because we can access main() outside of the class , if main() can’t be public then JVM(Java Virtual Machine) can’t be called main() & code can’t be executed.
● Static : static is a keyword in which the main method has to be static in which JVM can load the class into memory and call the main method without creating an instance.
● Void : Void is a data type. It means no return type.
● main(): Main is a function.
● String [] args : string means collection of characters ,String[] args represents a collection of Strings that are separated by a space and can be typed into the program on the terminal directly.

Line-4:

int i
Here i is a variable and int (Integer) is a data type of a variable.

Line-5:

for(i=1;i<=100;i++)
In this program use for loop .(i=1;i<=100;i + +) here apply the
logic .It means i value started from 1, continue this loop 100 times and
increment value 1 continuously while the program is not ending.

Line-7:

if(i==50)

Inside for loop use if condition . (i==50) means when i value is 50 the continue keyword will be used and hit this value.

Line-8:

System.out.println(“Now continue Hit”)

System: system is a predefined class. It is defined in java . Lang . package.

out: Out is a static variable of type printstream present in
system class.
println: It is a method of class printstream which shows the
result.

Line-9:

continue
The continue keyword can be used in any of the loops . It
causes the loop to immediately jump to the next iteration of the loop.

Line-11:

System.out.println(i)
System: system is a predefined class. It is defined in java.lang.package.
out: Out is a static variable of type printstream present in system class.
println: It is a method of class printstream which shows the result.

Conclusion:

Share Your Love
Avatar photo
SONALIN SAHOO

Myself Sonalin Shaoo. I am quite happy to contribute here some java programming content and my friends Lipsa Mohanty ,Sushil Puhan, Aswin Kumar Nayak also help me to contribute their Opinion on this .

Articles: 40

Newsletter Updates

Enter your email address below to subscribe to our newsletter