Thursday, August 8, 2013

Java Program To Print Stars In Triangle Shape

public class Triangle {

public static void main(String[] args) {
System.out.println("\n");
StringBuffer triangle = new StringBuffer();
for (int i = 0; i <= 5; i++) {
for (int j = i; j <= 5; j++) {
triangle.append(" ");
}
for (int k = 0; k <= i; k++) {
triangle.append("* ");
}
triangle.append("\n");
}

System.out.println(triangle);
}


}
















1 comment:

  1. Awesome. I am a beginner and this article helped me to resolve the problem .Thank

    you author and the whole expect team.

    http://www.wikitechy.com/view-article/java-program-to-print-a-stars-and-numbers-in-triangular-pattern


    Both are really good,
    Cheers,
    Venkat

    ReplyDelete