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 = "SIMPLE";
int i, j, k;
int length = str.length();
for (i = 0; i < length; i++)
{
for (j = length - 1; j > i; j--)
{
System.out.print(" ");
}
for (k = 0; k <= i; k++)
{
System.out.print(str.charAt(k) + " ");
}
System.out.println();
}
}
}
Output:
S
S I
S I M
S I M P
S I M P L
S I M P L E
