Java Tutorial
In java programming, this program is used to display triangle of * using nested for loop.
// Printing stars in triangle. public class TriangleStars { public static void main(String []args) { for(int i=1;i<=5;i++){ for(int j=1;j<=i;j++){ System.out.print("* "); } System.out.println(""); } } }Output:
D:\Java_Programs>javac TriangleStars.java D:\Java_Programs>java TriangleStars * * * * * * * * * * * * * * *
Java Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page