How to generate two right triangle of stars (*) with attached heads in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        for (int i = 7; i > 0; i--) {
            for (int j = 0; j < i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }

        for (int i = 1; i <= 7; i++) {
            for (int j = 0; j < i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}
 
/*

run:

*******
******
*****
****
***
**
*
*
**
***
****
*****
******
*******

*/

 



answered Oct 12, 2016 by avibootz

Related questions

1 answer 155 views
1 answer 181 views
1 answer 165 views
1 answer 171 views
1 answer 157 views
...