Hi friend,
import java.io.*;
public class TrianglesDemo{
final static int WIDTH = 10;
public static void main(String[] param) throws IOException{
InputStreamReader m = new InputStreamReader(System.in);
BufferedReader n = new BufferedReader(m);
System.out.print("Give me the size of each triangle : ");
int size = Integer.parseInt(n.readLine());
System.out.print("The number of triangles you want to output in each row : ");
int noOfTriangles = Integer.parseInt(n.readLine());
System.out.print("The number of rows of triangles you want to output : ");
int noOfRows = Integer.parseInt(n.readLine());
raster(size, noOfTriangles, noOfRows);
}
public static void raster(int a, int b, int c){
String result = "";
for(int Rows=1; Rows<=c; Rows++){
for(int triangles=1; triangles<=b; triangles++){
for (int Size = 1; Size <= WIDTH; Size++) {
for (int j = 1; j <= WIDTH -Size; j++) {
System.out.print(" ");
}
for (int j = 1; j <= 2*Size - 1; j++) {
System.out.print("*");
}
System.out.println();
}
System.out.println();
}
}
}
}
----------------------------------------
Visit for more information.
http://www.roseindia.net/java/Thanks.