Thursday, August 25, 2011

Java println example with for loop


//With out type n-number of print statement, using "for " loop we can create *-triangle like PrintStar1.java
public class PrintStar2
{
public static void main(String args[])
{
for(int i=1;i<10;i++) //for loop
{
for(int j=0;j {
System.out.print("*");
}
System.out.print("\n"); //new line
}
}
}

Out Put =>
*
**
***
****
*****
******
*******
********
*********

No comments:

Post a Comment