How to get characters in one row
https://code.sololearn.com/cFYfScs81fa6/?ref=app public class Pattern25 { public static void main(String args[]) { for(int i=1; i<=5; i++) { for(int j=1; j<=5;j++) { if(i==1 &&(j==1||j==2||j==3||j==4||j==5)) { System.out.print("*"); } else if(i==2 &&(j==1)) { System.out.print("*"); } else if(i==3 &&(j==1||j==2||j==3||j==4||j==5)) { System.out.print("*"); } else if(i==4 &&(j==5)) { System.out.print("*"); } else if(i==5 &&(j==1||j==2||j==3||j==4||j==5)) { System.out.print("*"); } else if(i==5 &&(j==1||j==2||j==3||j==4)) { System.out.print("*"); } else { System.out.print(" "); } } System.out.println(); } for(int i=1; i<=6; i++) { for(int j=1; j<=5;j++) { if(i==1) { System.out.print(" "); } if(i==2 &&(j==2||j==3||j==4)) { System.out.print("*"); } else if(i==3 &&(j==1||j==5)) { System.out.print("*"); } else if(i==4 &&(j==1||j==2||j==3||j==4||j==5)) { System.out.print("*"); } else if(i==5 &&(j==1||j==5)) { System.out.print("*"); } else if(i==6 &&(j==1||j==5)) { System.out.print("*"); } else { System.out.print(" "); } } System.out.println(); } for(int i=1; i<=6; i++) { for(int j=1; j<=5;j++) { if(i==1) { System.out.print(" "); } if(i==2 &&(j==1||j==5)) { System.out.print("*"); } else if(i==3 &&(j==1||j==5)) { System.out.print("*"); } else if(i==4 &&(j==1||j==2||j==3||j==4||j==5)) { System.out.print("*"); } else if(i==5 &&(j==1||j==5)) { System.out.print("*"); } else if(i==6 &&(j==1||j==5)) { System.out.print("*"); } else { System.out.print(" "); } } System.out.println(); } for(int i=1; i<=6; i++) { for(int j=1; j<=5;j++) { if(i==1) { System.out.print("