please explain java pattern programs
Answers
Java Interviews can give a hard time to programmers, such is the severity of the process. The ones who have attended the process will know that a pattern program is ought to pop up in the list of programs. This article precisely focuses on pattern programs in Java. I have classified the programs under the following clusters :
Pattern Programs in Java
Star Patterns in Java
Numeric Patterns
Character Patterns
Please mark me as brainlist
Program
package com.javainterviewpoint;
import java.util.Scanner;
public class Pattern1
{
public static void main(String[] args)
{
// Create a new Scanner object
Scanner scanner = new Scanner(System.in);
// Get the number of rows from the user
System.out.println("Enter the number of rows needed to print the pattern ");
int rows = scanner.nextInt();
System.out.println("## Printing the pattern ##");
// Print i number of stars
for (int i=1; i<=rows; i++)
{
for (int j=1; j<=i; j++)
{
System.out.print("*");
}
System.out.println();
}
scanner.close();
}
}
Output
Enter the number of rows needed to print the pattern
5
## Printing the pattern ##
*
**
***
****
*****