class ForLoopDemo{
public static void main(String args[]){
System.out.println("First pattern");
for(int i=1;i<=5;i++){
for(int j=1;j<=5;j++){
System.out.print("*");
}
System.out.println();
}
System.out.println("Second pattern");
for(int i=1;i<=5;i++){
for(int j=1;j<=i;j++){
System.out.print("*");
}
System.out.println();
}
System.out.println("Thrid pattern");
for(int i=1;i<=5;i++){
for(int j=5;i<=j;j--){
System.out.print("*");
}
System.out.println();
}
System.out.println("Foruth pattern");
for(int i=1;i<=5;i++){
for(int j=5;i<=j;j--){
System.out.print(j);
}
System.out.println();
}
System.out.println("Fifth pattern");
for(int i=1;i<=5;i++){
for(int j=5;i<=j;j--){
System.out.print(i);
}
System.out.println();
}
System.out.println("Sixth pattern");
for(int i=5;i>=1;i--){
for(int j=5;i<=j;j--){
System.out.print(i);
}
System.out.println();
}
System.out.println("Seventh pattern");
for(int i=5;i>=1;i--){
for(int j=1;j<=i;j++){
System.out.print(i);
}
System.out.println();
}
}
}
Output program is :
public static void main(String args[]){
System.out.println("First pattern");
for(int i=1;i<=5;i++){
for(int j=1;j<=5;j++){
System.out.print("*");
}
System.out.println();
}
System.out.println("Second pattern");
for(int i=1;i<=5;i++){
for(int j=1;j<=i;j++){
System.out.print("*");
}
System.out.println();
}
System.out.println("Thrid pattern");
for(int i=1;i<=5;i++){
for(int j=5;i<=j;j--){
System.out.print("*");
}
System.out.println();
}
System.out.println("Foruth pattern");
for(int i=1;i<=5;i++){
for(int j=5;i<=j;j--){
System.out.print(j);
}
System.out.println();
}
System.out.println("Fifth pattern");
for(int i=1;i<=5;i++){
for(int j=5;i<=j;j--){
System.out.print(i);
}
System.out.println();
}
System.out.println("Sixth pattern");
for(int i=5;i>=1;i--){
for(int j=5;i<=j;j--){
System.out.print(i);
}
System.out.println();
}
System.out.println("Seventh pattern");
for(int i=5;i>=1;i--){
for(int j=1;j<=i;j++){
System.out.print(i);
}
System.out.println();
}
}
}
Output program is :