Arrow pattern in java. Check out the print down arrow asterisk and number pattern program below in four different ways, each with a sample example and output. We added a compiler at the end of the program so that you can run the following codes.
While Loop in Java Program
A while loop in Java is a control flow statement that allows code to be executed several times based on a given Boolean condition. The while loop can be viewed as a looping if statement. A “While” Loop is used to iterate over a certain block of code until a condition is met. The condition is assessed first in a while loop, and if it returns true, the statements within the while loop are executed. When the condition returns false, the control exits the loop and moves on to the next line after the while loop.
If Else Statement in Java
If a particular condition is true, the if/else statement executes a block of code. If the condition is not met, another piece of code can be run. The if/else statement is a type of “Conditional” Statement in JavaScript, which is used to conduct different actions based on distinct situations.
Decrement Operator in Java
The increment unary operator in Java increases the value of a variable by one, and the decrement unary operator decreases the value of a variable by one. Both update the operand’s value to its new value. A decrement is a programming operator that reduces an operand’s numerical value by one.
Arrow Pattern in Java
public class Main
{
public static void main(String[] args)
{
int lines=6;
int i,j;
for(i=1;i<=lines;i++)
{
for(j=1;j<=lines;j++)
{
if(i==j)
System.out.print("*");
else
System.out.print("1");
}
j--;
System.out.print("*");
while(j>=1)
{
if(i==j)
System.out.print("*");
else
System.out.print("1");
j--;
}
System.out.println("");
}
}
}
Output:
*11111*11111*
1*1111*1111*1
11*111*111*11
111*11*11*111
1111*1*1*1111
11111***11111
Generate Random Number in C in Range
conio.h Header File Definition
Find Out Duplicate Number Between 1 to N Numbers in Java
How to Call a Method in Java From Another Class
C Program to Find Length of String Without Using strlen Function
fopen Function in C With Example
C++ Program to Find Grade of a Student Using If Else