Answers for "Diamond in java"

0

Diamond in java

public class DiamondPattren {
    public static void diamond() {

        for (int i = 1; i <= 5; i++) {
            for (int j = 1; j <= 5; j++) {
                if (j >= (5 - i + 1)) System.out.print("* ");
                else System.out.print("  ");
            }
            for (int j1 = 1; j1 <= 5; j1++) {
                if (j1 < i) System.out.print("* ");
                else System.out.print("  ");
            }
            System.out.println("");
        }

        for (int i1 = 1; i1 <= 4; i1++) {
            for (int j = 0; j <= 4; j++) {
                if (j <= (i1 - 1)) System.out.print("  ");
                else System.out.print("* ");
            }
            for (int j1 = 1; j1 <= 4; j1++) {
                if (j1 <= 4-i1) System.out.print("* ");
                else System.out.print("  ");
            }
            System.out.println("");
        }


    }
}
Posted by: Guest on August-26-2021

Code answers related to "Diamond in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language