Java Program to Print Left Arrow Star Pattern

Write a Java Program to print the left arrow pattern of stars using for loop. In this Java left arrow example, the first nested for loop set prints the left arrow top part, and the other code prints the left arrow bottom.

package ShapePrograms;

import java.util.Scanner;

public class LeftArrow1 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		int i, j;
		
		System.out.print("Enter Left Arrow Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Printing Left Arrow Star Pattern");
		
		for (i = 1 ; i <= rows; i++ ) 
		{
			for (j = 1 ; j <= rows - i; j++ ) 
			{
				System.out.print(" ");	
			}
			for (j = i ; j <= rows; j++ ) 
			{
				System.out.print("*");
			}
			System.out.println();
		}
		
		for (i = 1 ; i < rows; i++ ) 
		{
			for (j = 0 ; j < i; j++ ) 
			{
				System.out.print(" ");
			}
			for (j = 0 ; j <= i; j++ ) 
			{
				System.out.print("*");
			}
			System.out.println();
		}
	}
}
Java Program to Print Left Arrow Star Pattern 1

In this Java left arrow star pattern program, we replaced the for loop with a while loop.

package ShapePrograms;

import java.util.Scanner;

public class LeftArrow2 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Left Arrow Pattern Rows = ");
		int rows = sc.nextInt();
		
		int i = 1, j;
		
		System.out.println("Printing Left Arrow Star Pattern");
		
		while(i <= rows) 
		{
			j = 1 ;
			while ( j <= rows - i ) 
			{
				System.out.print(" ");	
				j++;
			}
			j = i;
			while(j <= rows ) 
			{
				System.out.print("*");
				j++;
			}
			System.out.println();
			i++;
		}
		i = 1;
		while (i < rows ) 
		{
			j = 0 ;
			while ( j < i) 
			{
				System.out.print(" ");
				j++;
			}
			j = 0 ;
			while (j <= i ) 
			{
				System.out.print("*");
				j++;
			}
			System.out.println();
			i++;
		}
	}
}
Enter Left Arrow Pattern Rows = 7
Printing Left Arrow Star Pattern
      *******
     ******
    *****
   ****
  ***
 **
*
 **
  ***
   ****
    *****
     ******
      *******

Java Program to Print Left Arrow Star Pattern using do while loop

package ShapePrograms;

import java.util.Scanner;

public class LeftArrow3 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Left Arrow Pattern Rows = ");
		int rows = sc.nextInt();
		
		int i = 1, j;
		
		System.out.println("Printing Left Arrow Star Pattern");
		
		do
		{
			j = 1 ;
			do
			{
				System.out.print(" ");	
			} while ( j++ <= rows - i ) ;
			j = i;
			do
			{
				System.out.print("*");
			} while(++j <= rows ) ;
			System.out.println();
		} while(++i <= rows) ;
		i = 1;
		do 
		{
			j = 0 ;
			do
			{
				System.out.print(" ");
			} while ( j++ < i) ;
			j = 0 ;
			do
			{
				System.out.print("*");

			} while (++j <= i ) ;
			System.out.println();

		} while (++i < rows );
	}
}
Enter Left Arrow Pattern Rows = 9
Printing Left Arrow Star Pattern
         *********
        ********
       *******
      ******
     *****
    ****
   ***
  **
 *
  **
   ***
    ****
     *****
      ******
       *******
        ********
         *********

In this Java example, the leftArrowPattern function prints the left arrow pattern of a given symbol.

package ShapePrograms;

import java.util.Scanner;

public class LeftArrow4 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Left Arrow Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.print("Enter Character for Left Arrow Pattern = ");
		char ch = sc.next().charAt(0);
		
		System.out.println("Printing Left Arrow Pattern");
		leftArrowPattern(rows, ch);
	}
	
	public static void leftArrowPattern(int rows, char ch) {
		int i, j;
		for (i = 1 ; i <= rows; i++ ) 
		{
			for (j = 1 ; j <= rows - i; j++ ) 
			{
				System.out.print(" ");	
			}
			for (j = i ; j <= rows; j++ ) 
			{
				System.out.print( ch);
			}
			System.out.println();
		}
		
		for (i = 1 ; i < rows; i++ ) 
		{
			for (j = 0 ; j < i; j++ ) 
			{
				System.out.print(" ");
			}
			for (j = 0 ; j <= i; j++ ) 
			{
				System.out.print(ch);
			}
			System.out.println();
		}
	}
}
Enter Left Arrow Pattern Rows = 11
Enter Character for Left Arrow Pattern = $
Printing Left Arrow Pattern
          $$$$$$$$$$$
         $$$$$$$$$$
        $$$$$$$$$
       $$$$$$$$
      $$$$$$$
     $$$$$$
    $$$$$
   $$$$
  $$$
 $$
$
 $$
  $$$
   $$$$
    $$$$$
     $$$$$$
      $$$$$$$
       $$$$$$$$
        $$$$$$$$$
         $$$$$$$$$$
          $$$$$$$$$$$