Print equilateral triangle in java
Below prints Equilateral Triangle. public class PrintEqulateralTriangle { public static void main(String[] args) { int numberOfRow = 10; int numberOfStars = numberOfRow + (numberOfRow - 1); int median = (numberOfStars+1)/2; for(int i=1; i<=numberOfRow; i++){ int start = (i==1 ? median : (median - i + 1)); int end = (i==1 ? median : (median + i - 1)); for(int j=1; j<=end;j++){ if((j>= start) && (j <= end)){ System.out.print("* "); }else{ System.out.print(" "); ...