136. JAVA Program to print triangle pattern using name.
How does this program work?
- This program is used to print triangle using with name in java.
Here is the code
//To print triangle pattern using name
import java.util.Scanner;public class pattern
{
public static void main(String[] args )
{
System.out.println("Enter a String: ");
Scanner sc = new Scanner(System.in );
String s = sc.nextLine();
int length= s.length();
char [] a=s.toCharArray();
System.out.println("\nPrinting the pattern: ");
for (int i = length-1; i >= 0; i--)
{
for (int j = 0; j <= i; j++)
{
System.out.print(a[j] );
}
System.out.println(" " );
}
}
}