Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
- /*
- Write a program to output the following pattern using for loop.
- 1
- 2
- 3
- 4
- 5
- */
- public class Diagonal {
- public static void main (String[]args) {
- for (int x=1; x<=5; x++){
- for (int y=1; y<=x; y++){
- System.out.print("");
- }
- System.out.println(x);
- }
- }
- }

Post new comment