how to print a pattern in Java
#java #how to print a pattern in Java #javaLearng #javacode #javatutorial
We have classified the Java pattern program into three categories:
Start Pattern
Number Pattern
Character Pattern
Below is Example and java program is run pattern of star as follows :-
The hyphens are printed after an odd number of stars.
After one star in line one.
After three stars in line two.
After five stars in line three.
public class Main { public static void main(String[] args) { // write your code here for (int i = 0; i < 6; i++) { for (int j = 0; j <= 11; j++) { System.out.print("*"); if (j == i * 2) { System.out.print(" - "); } } System.out.println(); } } }