In this tutorial, we will go through the string pattern program in java. Before that, you may go through the following topic in java.
String Pattern:
public class Main
{
public static void main(String args[])
{
String arr = "SIMPLE2CODE";
int n = 6;
int x = 0;
int i, j, k;
for (i = 0; i < n; i++)
{
for (j = n - 1; j > i; j--)
System.out.print(" ");
for (k = 0; k <= i; k++)
{
System.out.print(arr.charAt(x++) + " ");
if (x == arr.length())
x = 0;
}
System.out.println();
}
}
}
Output:
S I M P L E
S I M P L
S I M P
S I M
S I
S
