Java Code: Printing a Right-Angled Triangle Pattern - Corrected
There is a syntax error in the code. The class name should be 'Test3_2' instead of 'Test3 2'. Also, there are some errors in the use of semicolons and quotation marks. Here is the corrected code:
public class Test3_2 {
public static void main(String[] args) {
int i, j;
for (i = 0; i < 5; i++) {
for (j = 1; j < 5 - i; j++) {
System.out.print(" ");
}
for (j = 0; j <= i; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
This corrected code prints a right-angled triangle pattern using nested loops in Java. It demonstrates how to fix common syntax errors and follows best practices for Java code readability.
原文地址: https://www.cveoy.top/t/topic/f17m 著作权归作者所有。请勿转载和采集!