public class TriangleUtilities { public static String getRow(int numberOfStars) { String star = "*"; String output = ""; int n = numberOfStars; for(int i =1; i<=n; i++) { output += String.format("%s", star); } return output; } public static String getTriangle(int numberOfRows) { StringBuilder sb = new StringBuilder(); for(int i =1; i<=numberOfRows; i++) { sb.append(getRow(i) + "\n"); } return sb.toString(); } public static String getSmallTriangle() { return getTriangle(4); } public static String getLargeTriangle() { return getTriangle(9); } }