import java.util.*; public class TriangleUtilities { public static String getRow(int numberOfStars) { // Use StringBuilder and a loop StringBuilder stars = new StringBuilder(); for (int i = 0; i < numberOfStars; i++) { stars.append("*"); } String starTriangle = stars.toString(); return starTriangle; } public static String getTriangle(int numberOfRows) { StringBuilder stars = new StringBuilder(); for (int i = 1; i <= numberOfRows; i++) { for (int j = i; j > 0; j--) { stars.append("*"); } stars.append("\n"); } String starTriangle = stars.toString(); return starTriangle; } public static String getSmallTriangle() { StringBuilder stars = new StringBuilder(); for (int i = 1; i < 5; i++) { for (int j = i; j > 0; j--) { stars.append("*"); } stars.append("\n"); } String starTriangle = stars.toString(); return starTriangle; } public static String getLargeTriangle() { StringBuilder stars = new StringBuilder(); for (int i = 1; i < 10 ; i++) { for (int j = i; j > 0; j--) { stars.append("*"); } stars.append("\n"); } String starTriangle = stars.toString(); return starTriangle; } }