Best Patterns in Java Program for 2024

Best Patterns Que. in java program , Star pattern in java ,character pattern in java , number Pattern in java for learn patterns


Q. Write a Java code for following character Pattern.?

Patterns in java program , Star pattern in java ,char pattern in java , number Pattern in java

111111
1111
11

class Pattarn_new1
{
public static void main(String args[])
{
int i,j,k=3;
for(i=1;i<=k;i++)
 { for(j=1;j<=i;j++)
  {System.out.print(" ");}
for(j=(k*2);j>=(i*2)-1;j--)
{System.out.print("1");}
 System.out.print("\n");
}
}
}

Q. Write a Java code for following character Pattern.?

Patterns in java program , Star pattern in java ,char pattern in java , number Pattern in java

a
ab
abb
abbb

class Pattarn_new2
{
public static void main(String args[])
{
int i,j;
for(i=1;i<=4;i++)
 {for(j=1;j<=i;j++)
{if(j==1)
 System.out.print("a");
else
{
System.out.print("b");}
}
System.out.print("\n");
}
}
}

Q. Write a Java code for following character Pattern.?

Patterns in java program , Star pattern in java ,char pattern in java , number Pattern in java

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

Patterns in java program , Star pattern in java ,char pattern in java , number Pattern in java

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25

class Pattarn_new4
{
public static void main(String args[])
{
int i,j,k=1;
for(i=1;i<=5;i++)
 {for(j=1;j<=5;j++)
{System.out.print(k+"\t");
k++;
}
System.out.print("\n");
}
}
}

Q. Write a Java code for following character Pattern.?

Patterns in java program , Star pattern in java ,char pattern in java , number Pattern in java

aaaabbbbaaaa
aaabbbaaa
aabbaa
aba

class Pattarn_new7
{
public static void main(String args[])
{
int r,c,k;
k=4;
for(r=1;r<=4;r++)
{
  for(c=r;c>1;c--)
  {
   System.out.print(" ");
  }
  for(c=k;c>=1;c--)
  {
   System.out.print("a");
  }
  for(c=k;c>=1;c--)
  {System.out.print("b");
  }
  for(c=k;c>=1;c--)
  {System.out.print("a");
  }k--;
System.out.println(" ");
}
}}

Q. Write a Java code for following character Pattern.?

Patterns in java program , Star pattern in java ,char pattern in java , number Pattern in java

******
*****
****
***
**
*
class Pattarn_new8
{
public static void main(String args[])
{
int r,c;
for(r=5;r>=1;r--)
{
 for(c=r;c>=1;c--)
{System.out.print("*");
}
System.out.println(" ");
}
}}

Q. Write a Java code for following character Pattern.?

Patterns in java program , Star pattern in java ,char pattern in java , number Pattern in java


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

 for(j=9-k;j>=1;j--)
{System.out.print("*");}
k=k+3;
System.out.print("\n");
}
}
}

Q. Write a Java code for following character Pattern.?

Patterns in java program , Star pattern in java ,char pattern in java , number Pattern in java

1000
0100
0010
0001

class Pattarn_new10
{
public static void main(String args[])
{
int i,j;
for(i=1;i<=4;i++)
 { 
  for(j=1;j<=4;j++)
  {
  if(j==i)
   {System.out.print("1");}      //for when i==j print 1
  else
    {System.out.print("0");}      //for when i!=0 print 0
  }
System.out.print("\n");
}
}
}

Q. Write a Java code for following character Pattern.?

Patterns in java program , Star pattern in java ,char pattern in java , number Pattern in java

1010101
0101010
1010101
0101010
1010101
0101010
1010101

class Pattarn_exam1
{
public static void main(String args[])
{
int i,j,k=1;
for(i=1;i<=7;i++)
  {
for(j=1;j<=7;j++)
 {
if(k%2==0)
 {
 System.out.print("0");
  }
 else
{
 System.out.print("1");
}
k++;
}
System.out.print("\n");
}
}
}

Q. Write a Java code for following character Pattern.?

Patterns in java program , Star pattern in java ,char pattern in java , number Pattern in java

1
2 6
3 7 10
4 8 11 13
5 9 12 14 15

class Pattarn_exam2
{
public static void main(String args[])
{
int i,j,k;
for(i=1;i<=5;i++)
  {k=i;
for(j=1;j<=i;j++)
 {
  System.out.print(k+" ");
 k=k+(5-j);
 }
 System.out.print("\n");
}
}
}
 

Best Patterns Que. in java program , Star pattern in java ,character pattern in java , number Pattern in java for learn patterns

Leave a Comment