Playing with Pattern and for loop in Java By Aryadrj

Java Pattern programs

Aryadrj©2017-2021
Author: Aryadrj
Time took: 2 days



Pattern 1

****
****
****
****
Pattern 2

1111
2222
3333
4444

Pattern 3

4444
3333
2222
1111
Pattern 4

1234
1234
1234
1234
Pattern 5

4321
4321
4321
4321
Pattern6

4321
3333
4321
1111
Pattern7

4321
****
4321
****
Pattern8

4444
****
2222
****
Pattern9

1111
****
3333
****
Pattern10

****
1234
****
1234
Pattern11

DCBA
CCCC
DCBA
AAAA
Pattern12

DCBA
****
DCBA
****
Pattern13

DDDD
****
BBBB
****

Pattern14

AAAA
****
CCCC
****
Pattern15

****
ABCD
****
ABCD
Pattern16

****
CCCC
****
AAAA
Pattern17

****
*CB*
*CB*
****
Pattern18

ABCD
A  D
A  D
ABCD
Pattern19

ABCD
EFGH
IJKL
MNOP
Pattern20

*
**
***
****

Pattern21

1
22
333
4444
Pattern22

1
12
123
1234
Pattern23

4
43
432
4321
Pattern24

4
33
222
1111
Pattern25

4
33
432
1111
Pattern26

4
**
222
****
Pattern27

1
**
333
****
Pattern28

*
12
***
1234
Pattern29

*
33
***
1111
Pattern30

  *
  **
 ***
****
Pattern31

   1
  22
 333
4444

Pattern32

   1
  12
 123
1234
Pattern33
   
4
  33
 222
1111
Pattern34

   1
  23
 456
78910
Pattern35

   10
  98
 765
4321
Pattern36

   a
  bb
 ccc
dddd
Pattern37

   d
  cc
 bbb
aaaa
Pattern38

a
  bc
 def
ghij
Pattern39

   a
  ab
 abc
abcd
Pattern40

   d
  dc
 dcb
dcba
Pattern41

   1
  **
 333
****
Pattern42

   a
  **
 ccc
****
Pattern43

   *
  22
 ***
4444
Pattern44

  j
  ih
 gfe
dcba
Pattern45

   *
  ***
 *****
*******
Pattern46

   1
  222
 33333
4444444
Pattern47

   4
  333
 22222
1111111
Pattern48

1
  123
 12345
1234567
Pattern49

   a
  bbb
 ccccc
ddddddd
Pattern50

d
  ccc
 bbbbb
aaaaaaa
Pattern51

   a
  222
 ccccc
4444444

Pattern52

  *
  123
 33333
*******

Pattern53

****
 ***
  **
   *
Pattern54

1111
 222
  33
   4
Pattern55

1234
 123
  12
   1
Pattern56

1234
 567
  89
   10


Pattern57

4444
 333
  22
   1

Pattern58

10987
 654
  32
   1
Pattern59

dddd
 ccc
  bb
   a
Pattern60

abcd
 abc
  ab
   a
Pattern61

abcd
 efg
  hi
   j
Pattern62

aaaa
 bbb
  cc
   d
Pattern63

****
 123
  **
   1
Pattern64

1234
 ***
  12
   *
Pattern65

4321
 432
  43
   4
Pattern66

1111
 bbb
  33
   d
Pattern67

*******
 *****
  ***
   *
Pattern68

1111111
 22222
  333
   4
Pattern69

1234567
 12345
  123
   1
Pattern70

7654321
 76543
  765
   7
Pattern71

aaaaaaa
 bbbbb
  ccc
   d
Pattern72

ddddddd
 ccccc
  bbb
   a
Pattern73

abcdefg
 abcde
  abc
   a
Pattern74

1111111
 bbbbb
  333
   d
Pattern75

*******
 abcde
  123
   *
Pattern76


Pattern77


Pattern78
Pattern79
Pattern80


Pattern81

*    ******
* ** * 11  
* ** * 11  
***********
  22 * ** *
  22 * ** *
******    *


1. Write a Java program to print like

****
****
****
****

class Pattern1
{
public static void main(String args[])
{
for(int i=1;i<=4;i++)
{
for(int j=1;j<=4;j++)
{
System.out.print("*");
}
System.out.println();
    }
}
}

2. Write a Java program to print like


1111
2222
3333
4444

class Pattern2
{
public static void main(String args[])
{
for(int i=1;i<=4;i++)
{
for(int j=1;j<=4;j++)
{
System.out.print(i);
}
System.out.println();
    }
}
}


3. Write a Java program to print like

4444
3333
2222
1111

class Pattern3
{
public static void main(String args[])
{
for(int i=4;i>=1;i--)
{
for(int j=1;j<=4;j++)
{
System.out.print(i);
}
System.out.println();
    }
}
}

4. Write a Java program to print like

1234
1234
1234
1234

class Pattern4
{
public static void main(String args[])
{
for(int i=4;i>=1;i--)
{
for(int j=1;j<=4;j++)
{
System.out.print(j);
}
System.out.println();
    }
}
}

5. Write a Java program to print like

4321
4321
4321
4321

class Pattern5
{
public static void main(String args[])
{
for(int i=4;i>=1;i--)
{
for(int j=4;j>=1;j--)
{
System.out.print(j);
}
System.out.println();
    }
}

}

6. Write a Java program to print like

4321
3333
4321
1111


class Pattern6
{
public static void main(String args[])
{
for(int i=4;i>=1;i--)
{
for(int j=4;j>=1;j--)
{
if(i%2==0)
{
System.out.print(j);
}
else
{
System.out.print(i);
}
}
System.out.println();
    }
}
}

7. Write a Java program to print like

4321
****
4321
****

class Pattern7
{
public static void main(String args[])
{
for(int i=4;i>=1;i--)
{
for(int j=4;j>=1;j--)
{
if(i%2==0)
{
System.out.print(j);
}
else
{
System.out.print("*");
}
}
System.out.println();
 }
}
}


8. Write a java program to print pattern like this

1111
****
3333
****

class Pattern9
{
public static void main(String args[])
{
for (int i=1;i<=4;i++)
{
for(int j=1;j<=4;j++)
{
if(i%2!=0)
{
System.out.print(i);
}
else
{
System.out.print("*");
}
}
System.out.println();
}
}
}

9. Write a java program to print pattern like this

****
1234
****
1234

class Pattern10
{
public static void main(String args[])
{
for (int i=1;i<=4;i++)
{
for(int j=1;j<=4;j++)
{
if(i%2!=0)
{
System.out.print("*");
}
else
{
System.out.print(j);
}
}
System.out.println();
}
}
}


10. Write a java program to print pattern like this

DCBA
CCCC
DCBA
AAAA


class Pattern11

{

public static void main(String args[])

{

for (char i='D';i>='A';i--)

{

for(char j='D';j>='A';j--)

{

if(i%2==0)

{

System.out.print(j);

    }

else

{

System.out.print(i);

}

}


System.out.println();
}
}
}


11. Write a java program to print pattern like this

DCBA
****
DCBA
****

class Pattern12
{
public static void main(String args[])
{
for (char i='D';i>='A';i--)
{
for(char j='D';j>='A';j--)
{
if(i%2==0)
{
System.out.print(j);
    }
else
{
System.out.print("*");
}
}
System.out.println();
}
}
}

12.

class Pattern12
{
public static void main(String args[])
{
for (char i='D';i>='A';i--)
{
for(char j='D';j>='A';j--)
{
if(i%2==0)
{
System.out.print(j);
    }
else
{
System.out.print("*");
}
}

System.out.println();
}

}

}

13.

class Pattern13
{
public static void main(String args[])
{
for (char i='D';i>='A';i--)
{
for(char j='D';j>='A';j--)
{
if(i%2==0)
{
System.out.print(i);
    }
else
{
System.out.print("*");
}
}

System.out.println();
}

}

}

14.
class Pattern14
{
public static void main(String args[])
{
for (char i='A';i<='D';i++)
{
for(char j='A';j<='D';j++)
{
if(i%2!=0)
{
System.out.print(i);
    }
else
{
System.out.print("*");
}
}

System.out.println();
}

}

}

15.

public class Pattern15 {
public static void main(String args[])
{
for (char i='A';i<='D';i++)
{
for(char j='A';j<='D';j++)
{
if(i%2!=0)
{
System.out.print("*");
    }
else
{
System.out.print(j);
}
}

System.out.println();
}

}


}

16.

public class Pattern16 {
public static void main(String args[])
{
for (char i='D';i>='A';i--)
{
for(char j='D';j>='A';j--)
{
if(i%2==0)
{
System.out.print("*");
    }
else
{
System.out.print(i);
}
}

System.out.println();
}

}


}

17.


public class Pattern17 {
public static void main(String args[])
{
for (char i='D';i>='A';i--)
{
for(char j='D';j>='A';j--)
{
if(i=='A' || i=='D' || j=='A' || j=='D')
{
System.out.print("*");
    }
else
{
System.out.print(j);
}
}

System.out.println();
}

}


}

18.

class Pattern18
{
public static void main(String args[])
{
for (char i='A';i<='D';i++)
{
for(char j='A';j<='D';j++)
{
if( i=='A'||i=='D'||j=='A'||j=='D')
{
System.out.print(j);
}
else
{
System.out.print(" ");
}
}

System.out.println();
}

}

}

19.

class Pattern19
{
public static void main(String args[])
{
char no='A';
for (char i='A';i<='D';i++)
{
for(char j='A';j<='D';j++)
{
System.out.print(no);
no++;
}

System.out.println();
}

}

}

20.


class Pattern20
{
public static void main(String args[])
{
for (int i=1;i<=4;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print("*");
}

System.out.println();
}

}
}

21.


class Pattern21
{
public static void main(String args[])
{
for (int i=1;i<=4;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(i);
}

System.out.println();
}

}
}

22.

class Pattern22
{
public static void main(String args[])
{
for (int i=1;i<=4;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(j);
}

System.out.println();
}

}

}

23.

class Pattern23
{
public static void main(String[] args) {
{
for(int i=4;i>=1;i--)
{
for(int j=4;j>=i;j--)
{
System.out.print(j);
}
System.out.println();
}

}
}

}

24.

class Pattern24
{
public static void main(String[] args) {
{
for(int i=4;i>=1;i--)
{
for(int j=4;j>=i;j--)
{
System.out.print(i);
}
System.out.println();
}

}
}

}

25.

class Pattern25
{
public static void main(String[] args) {
{
for(int i=4;i>=1;i--)
{
for(int j=4;j>=i;j--)
    if(i%2!=0)
{
System.out.print(i);
}
    else
    {
    System.out.print(j);
    }
System.out.println();
}

}
}

}

26.

class Pattern26
{
public static void main(String[] args) {
{
for(int i=4;i>=1;i--)
{
for(int j=4;j>=i;j--)
    if(i%2==0)
{
System.out.print(i);
}
    else
    {
    System.out.print("*");
    }
System.out.println();
}

}
}

}


27.

class Pattern27
{
public static void main(String args[])
{
for (int i=1;i<=4;i++)
{
for(int j=1;j<=i;j++)
{
if(i%2!=0)
{
System.out.print(i);
}
else
{
System.out.print("*");

}
}

System.out.println();
}

}

}


28.

class Pattern28
{
public static void main(String args[])
{
for (int i=1;i<=4;i++)
{
for(int j=1;j<=i;j++)
{
if(i%2==0)
{
System.out.print(j);
}
else
{
System.out.print("*");

}
}

System.out.println();
}

}

}

29.

class Pattern29
{
public static void main(String args[])
{
for (int i=4;i>=1;i--)
{
for(int j=4;j>=i;j--)
{
if(i%2==0)
{
System.out.print("*");
}
else
{
System.out.print(i);

}
}

System.out.println();
}

}

}


30.


public class Pattern30 {
public static void main(String[] args) {
int star=1;
int space=3;
for (int i = 1; i <=4; i++) 
{
for (int j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print("*");
}
star++;
space--;
System.out.println();
}
}

}

31.


public class Pattern31 {
public static void main(String[] args) {
int star=1;
int space=3;
for (int i = 1; i <=4; i++) 
{
for (int j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(i);
}
star++;
space--;
System.out.println();
}
}

}

32.


public class Pattern32 {
public static void main(String[] args) {
int star=1;
int space=3;
for (int i = 1; i <=4; i++) 
{
for (int j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(k);
}
star++;
space--;
System.out.println();
}
}

}

33.


public class Pattern33 {
public static void main(String[] args) {
int star=1;
int space=3;
int j;
for (int i = 1; i <=4; i++) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(j);
}
star++;
space--;
System.out.println();
}
}

}

34.


public class Pattern34 {
public static void main(String[] args) {
int star=1;
int space=3;
int no=10;
int j;
for (int i = 1; i <=4; i++) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(no);
no--;
}
star++;
space--;
System.out.println();
}
}

}

35.


public class Pattern35 {
public static void main(String[] args) {
int star=1;
int space=3;
int j;
int no=10;
for (int i = 1; i <=4; i++) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(no);
no--;
}
star++;
space--;
System.out.println();
}
}

}

36.


public class Pattern36 {
public static void main(String[] args) {
int star=1;
int space=3;
int j;
for (char i = 'a'; i <='d'; i++) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(i);
}
star++;
space--;
System.out.println();
}
}

}

37.


public class Pattern37 {
public static void main(String[] args) {
int star=1;
int space=3;
int j;
for (char i = 'd'; i >='a'; i--) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(i);
}
star++;
space--;
System.out.println();
}
}

}

38.


public class Pattern38 {
public static void main(String[] args) {
int star=1;
int space=3;
char z='a';
int j;
for (char i = 'd'; i >='a'; i--) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(z);
z++;
}
star++;
space--;
System.out.println();
}
}
}

39.

public class Pattern39 {
public static void main(String[] args) {
char star='a';
int space=3;
int j;
for (char i = 'a'; i <='d'; i++) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for ( char k='a'; k <=star; k++) 
{
System.out.print(k);
}
star++;
space--;
System.out.println();
}
}

}

40.

public class Pattern40 {
public static void main(String[] args) {
//int star=1;
int space=3;
int j;
for (char i = 'd'; i >='a'; i--) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (char k ='d';k>=i; k--) 
{
System.out.print(k);
}
space--;
System.out.println();
}
}

}

41.


public class Pattern41 {
public static void main(String[] args) {
int star=1;
int space=3;
int j;
for (int i = 1; i <=4; i++) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for ( int k=1; k <=star; k++) 
{
if(i%2!=0)
{
System.out.print(i);
}
else
{
System.out.print("*");
}
}
star++;
space--;
System.out.println();
}
}

}

42.


public class Pattern42{
public static void main(String[] args) {
int star=1;
int space=3;
int j;
for (char i = 'a'; i <='d'; i++) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
if(i%2!=0)
{
System.out.print(i);
}
else
{
System.out.print("*");
}

}
star++;
space--;
System.out.println();
}
}

}

43.

public class Pattern43 {
public static void main(String[] args) {
int star=1;
int space=3;
int j;
for (int i = 1; i <=4; i++) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for ( int k=1; k <=star; k++) 
{
if(i%2==0)
{
System.out.print(i);
}
else
{
System.out.print("*");
}
}
star++;
space--;
System.out.println();
}
}

}


44.


public class Pattern44 {
public static void main(String[] args) {
int star=1;
int space=3;
char z='j';
int j;
for (char i = 'd'; i >='a'; i--) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(z);
z--;
}
star++;
space--;
System.out.println();
}
}

}

45.


public class Pattern45 {
public static void main(String[] args) {
int star=1;
int space=3;
for (int i = 1; i <=4; i++) 
{
for (int j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print("*");
}
star=star+2;
space--;
System.out.println();
}
}

}

46.

public class Pattern46 {
public static void main(String[] args) {
int star=1;
int space=3;
for (int i = 1; i <=4; i++) 
{
for (int j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(i);
}
star=star+2;
space--;
System.out.println();
}
}

}

47.

public class Pattern47 {
public static void main(String[] args) {
int star=1;
int space=3;
int j;
for (int i = 1; i <=4; i++) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(j);
}
star=star+2;
space--;
System.out.println();
}
}

}

48.

public class Pattern48{
public static void main(String[] args) {
int star=1;
int space=3;
int j;
for (int i = 1; i <=4; i++) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(k);
}
star=star+2;
space--;
System.out.println();
}
}

}

50.


public class Pattern50 {
public static void main(String[] args) {
int star=1;
int space=3;
int j;
for (char i = 'd'; i >='a'; i--) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
System.out.print(i);
}
star=star+2;
space--;
System.out.println();
}
}

}

51.


public class Pattern51 {
public static void main(String[] args) {
int star=1;
int space=3;
int j;
int l=0;
for (char i = 'a'; i <='d'; i++) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
if(i=='a' || i=='c')
{
  System.out.print(i);
}
else if(i=='b')
{
System.out.print("2");
}
else
{
System.out.print("4");
}

}
star=star+2;
space--;
System.out.println();
}
}

}

52.


public class Pattern52 {
public static void main(String[] args) {
int star=1;
int space=3;
int j;
int l=0;
for (char i = 'a'; i <='d'; i++) 
{
for (j = 1; j <= space; j++) 
{
System.out.print(" ");

}
for (int k = 1; k <=star; k++) 
{
if(i=='a' || i=='d')
{
  System.out.print("*");
}
else if(i=='b')
{
System.out.print(k);
}
else
{
System.out.print("3");
}

}
star=star+2;
space--;
System.out.println();
}
}

}

53.

public class Pattern53
{
public static void main(String args[])
{
int star=4;
int space=0;
for(int  i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
System.out.print("*");
}
star--;
space++;
System.out.println();
}
}

}

54.

public class Pattern54
{
public static void main(String args[])
{
int star=4;
int space=0;
for(int  i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
System.out.print(i);
}
star--;
space++;
System.out.println();
}
}

}

55.

public class Pattern55
{
public static void main(String args[])
{
int star=4;
int space=0;
for(int  i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
System.out.print(k);
}
star--;
space++;
System.out.println();
}
}

}

56.

public class Pattern56
{
public static void main(String args[])
{
int star=4;
int space=0;
int no=1;
for(int  i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
System.out.print(no);
no++;
}
star--;
space++;
System.out.println();
}
}

}

57.

public class Pattern57
{
public static void main(String args[])
{
int star=4;
int space=0;
for(int  i=4;i>=1;i--)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
System.out.print(i);
}
star--;
space++;
System.out.println();
}
}

}

58.

public class Pattern58
{
public static void main(String args[])
{
int star=4;
int space=0;
int no=10;
for(int  i=4;i>=1;i--)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
System.out.print(no);
no--;
}
star--;
space++;
System.out.println();
}
}

}

59.
public class Pattern59
{
public static void main(String args[])
{
int star=4;
int space=0;
char no='a';
for(char  i='d';i>='a';i--)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
System.out.print(no);
no++;
}
star--;
space++;
System.out.println();
}
}

}

60.
public class Pattern60
{
public static void main(String args[])
{
char star='d';
int space=0;
for(int  i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(char k='a';k<=star;k++)
{
System.out.print(k);
}
star--;
space++;
System.out.println();
}
}

}

61.

public class Pattern61
{
public static void main(String args[])
{
char star='d';
int space=0;
char al='a';
for(char  i='d';i>='a';i--)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(char k='a';k<=star;k++)
{
System.out.print(al);
al++;
}
star--;
space++;
System.out.println();
}
}

}

62.

public class Pattern62
{
public static void main(String args[])
{
char star='d';
int space=0;
for(char  i='a';i<='d';i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(char k='a';k<=star;k++)
{
System.out.print(i);
}
star--;
space++;
System.out.println();
}
}

}

63.

public class Pattern63
{
public static void main(String args[])
{
int star=4;
int space=0;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
if(i==1 || i==3)
{
System.out.print("*");
}
else
{
System.out.print(k);
}
}
star--;
space++;
System.out.println();
}
}

}

64.

public class Pattern64
{
public static void main(String args[])
{
int star=4;
int space=0;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
if(i==2 || i==4)
{
System.out.print("*");
}
else
{
System.out.print(k);
}
}
star--;
space++;
System.out.println();
}
}

}

65.

public class Pattern65
{
public static void main(String args[])
{
int star=1;
int space=0;
for(int  i=4;i>=1;i--)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=4;k>=star;k--)
{
System.out.print(k);
}
star++;
space++;
System.out.println();
}
}

}


66.

public class Pattern66
{
public static void main(String args[])
{
int star=4;
int space=0;
for(int  i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
if(i==1 || i==3)
{
System.out.print(i);
}
else if(i==2)
{
System.out.print("b");
}
else
{
System.out.println("d");
}
}
star--;
space++;
System.out.println();
}
}

}

67.

public class Pattern67
{
public static void main(String[] args) {
int star=7;
int space=0;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
System.out.print("*");
}
space++;
star-=2;
System.out.println();
}
}
}

68.

public class Pattern68
{
public static void main(String[] args) {
int star=7;
int space=0;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
System.out.print(i);
}
space++;
star-=2;
System.out.println();
}
}

}

69.

public class Pattern69
{
public static void main(String[] args) {
int star=7;
int space=0;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=1;k<=star;k++)
{
System.out.print(k);
}
space++;
star-=2;
System.out.println();
}
}

}

70.

public class Pattern70
{
public static void main(String[] args) {
int star=1;
int space=0;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=7;k>=star;k--)
{
System.out.print(k);
}
space++;
star+=2;
System.out.println();
}
}

}

71.

public class Pattern71
{
public static void main(String[] args) {
int star=1;
int space=0;
for(char i='a';i<='d';i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=7;k>=star;k--)
{
System.out.print(i);
}
space++;
star+=2;
System.out.println();
}
}

}

72.

public class Pattern72
{
public static void main(String[] args) {
int star=1;
int space=0;
for(char i='d';i>='a';i--)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(int k=7;k>=star;k--)
{
System.out.print(i);
}
space++;
star+=2;
System.out.println();
}
}

}

73.

public class Pattern73
{
public static void main(String[] args) {
char star='g';
int space=0;
for(char i='d';i>='a';i--)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(char k='a';k<=star;k++)
{
System.out.print(k);
}
space++;
star-=2;
System.out.println();
}
}

}

74.

public class Pattern74
{
public static void main(String[] args) {
char star='g';
int space=0;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(char k='a';k<=star;k++)
{
if(i==1 || i==3)
{
System.out.print(i);
}
else if(i==2)
{
System.out.print("b");
}
else
{
System.out.print("d");
}
}
space++;
star-=2;
System.out.println();
}
}

}

75.

public class Pattern75
{
public static void main(String[] args) {
char star='g';
int space=0;
int s=1;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=space;j++)
{
System.out.print(" ");
}
for(char k='a';k<=star;k++)
{
if(i==1)
{
System.out.print("*");
}
else if(i==2)
{
System.out.print(k);
}
else if(i==3)
{
System.out.print(s);
s++;
}
else
{
System.out.println("*");
}
}
space++;
star-=2;
System.out.println();
}
}

}


81. (Swastic pattern in java)


public class Pattern81{
public static void main(String[] args) 
{
for(int i=1;i<=7;i++)
{
for(int j=1;j<=11;j++)
{
if((((i==1 && j==2) || (i==2 && j==2))||(i==7 && j==10)||(i==7 && j==9)
||(i==7 && j==8)||(i==7 && j==7)||(i==6 && j==7)||(i==6 && j==10)||(i==6 && j==5)||(i==5 && j==5)||(i==5 && j==7)
||(i==5 && j==10)||(i==3 && j==2)||(i==3 && j==7)||(i==3 && j==10)||(i==3 && j==11)||(i==3 && j==5)||(i==2 && j==5)
||(i==2 && j==7)||(i==2 && j==10)||(i==2 && j==11)||(i==1 && j==3)||(i==1 && j==4)||(i==1 && j==5) ||(i==3 && j==2)
||(i==5 && j==2)||(i==5 && j==1)||(i==6 && j==2)||(i==6 && j==1)))
System.out.print(" ");
else if(((i==2 && j==9)||(i==2 && j==8))||(i==3 && j==9)||(i==3 && j==8))
System.out.print("1");
else if(((i==6 && j==3)||(i==6 && j==4))||(i==5 && j==3)||(i==5 && j==4))
System.out.print("2");
else
System.out.print("*");
}
System.out.println();
}
}

}








































tags-
java patterns,swastic,printing star

Comments

Popular posts from this blog

How to set image in carousel using flask?

Invalid syntax , perhaps you forgot a comma? Error in Python

How to run PL/SQL Code With Command Line?