Print Star in-between of Numbers in Java

Print star in-between of numbers in java. This java pattern program will print the star pattern in between of the number pattern. 

public class Main
{
public static void main(String []args)
{
int i,j,lines=5;
for(i=1;i<=lines;i++)
{
for(j=lines;j>=1;j--)
{
if(j!=i)
System.out.print(j);
else
System.out.print("*");
}
System.out.println("");
}

}

}

 

Output:

5432*
543*1
54*21
5*321
*4321

Not - Equal Operator in Java

The not-equal operator,!=, does the opposite, returning true if the values are not equal. == and!= are typically used with primitives such as int and boolean, not with objects such as String and Color.

If Else Statement in Java

If the Boolean expression returns true, the if block is executed; otherwise, the else block is executed. Any non-zero and non-null value is assumed to be true in the C programming language, but any zero or null value is assumed to be false. 

The if statement is a decision-making structure made up of an expression followed by one or more statements. The if else structure is a decision-making structure in which the if statement is followed by an optional else statement that executes if the expression is false.