fork download
  1. public class TrianglePattern {
  2. public static void printTrianglePattern(Integer rows) {
  3. // Iterate through each row of the triangle
  4. for (Integer i = 1; i <= rows; i++) {
  5. // Print asterisks for the current row
  6. for (Integer j = 1; j <= i; j++) {
  7. System.debug('*');
  8. }
  9. // Move to the next line
  10. System.debug('\n');
  11. }
  12. }
  13. }
  14. Integer triangleHeight = 5;
  15. TrianglePattern.printTrianglePattern(triangleHeight);
Success #stdin #stdout #stderr 0.01s 8996KB
stdin
Standard input is empty
stdout
Object: UndefinedObject error: did not understand #TrianglePattern
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject class(Object)>>doesNotUnderstand: #TrianglePattern (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:1)
stderr
./prog:2: parse error, expected '}'