For Loop in Java | Coding Startup

For Loop in Java

For Loop in Java.

100% Working Code and Projects.


if you need any help about project and Application Contact Shelly at:+917888361589.


Java Code given below:-

package CodingStartupAbheer;

import java.util.Scanner;

public class ForLoop {

    public static void main(String Abheer[]) {
        Scanner S = new Scanner(System.in);
        System.out.println("Enter the name");
        String a = S.next();
        System.out.println("How many times you want to print");
        int b=S.nextInt();
        for (int i=1;i<=b;i++)
        {
            System.out.println(a);
        }
    }
}



Output :-

Enter the name
CodingStartup
How many times you want to print
4
CodingStartup
CodingStartup
CodingStartup
CodingStartup


Explanation:-

In this loop, 1) we initialize the value 
2) give the condition 
3) we increment the value
this will work only when the condition is true. when the condition get false it will stop executing the code.



Code Startup

Author & Editor

0 Comments:

Post a Comment