simple triangle program in java
import java.lang.*;
public class Triangle {
// public is access specifiers Triangle is a class name it should star with capital latter
public static void main(String a[])
//Static ia key word main is a method and String is a class
//"a" is variable it stores value in array formate
{
int i,j; // int is adata type i and j are variables
for(i=1; i<10;i++) //first check condition here if it is true then go to next for loop
{
for(j=i;j<10;j++)
{
System.out.print(+j);
}
System.out.println();
//here System is a class and out is stream and println is a method
}
}
}
output :--
123456789
23456789
3456789
456789
56789
6789
789
89
9
No comments:
Post a Comment