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 str = "SIMPLE2CODE";
int n = 6;
int x = 0;
int i, j;
for (i = 0; i < n; i++)
{
for (j = 0; j <= i; j++)
{
System.out.print(str.charAt(x++) + " ");
if (x == str.length())
x = 0;
}
System.out.println();
}
}
}
Output:
S
I M
P L E
2 C O D
E S I M P
L E 2 C O D
