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:
import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
String str;
int i, j;
char[] ch;
Scanner sc = new Scanner(System.in);
System.out.print("Enter a Word: ");
str = sc.nextLine();
ch = str.toCharArray();
int strLength = ch.length;
for (i = 0; i < strLength; i++)
{
for (j = 1; j <= strLength; j++)
{
System.out.print(str.charAt(strLength - j) + " ");
}
System.out.println();
}
}
}
Output:
Enter a Word: SIMPLE
E L P M I S
E L P M I S
E L P M I S
E L P M I S
E L P M I S
E L P M I S
