Java2all.com  

Relational Operators





Share This Topic -

 

OPERATOR

MEANING

EXPLANATION

EXAMPLE

RESULT

==

Equal to

This sign is for check equality

10==10

true

!=

Not equal to

This sign is for check Inequality

10!=10

false

Greater than

This sign is for check greater value

10>10

false

Less than

This sign is for check lesser value

10<10

false

>=

Greater than or equal to

This sign is for check greater as well as equality

10>=10

true

<=

Less than or equal to

This sign is for check lesser as well as equality

10<=10

true

 
EX.
 public class RelationalDemo 
{
	public static void main(String[] args) 
	{
		System.out.println("..............Relational operators.................");
		int mark = 70;
		if(mark != 0)	// != Not equal to 
		{
		if(mark == 65 | mark > 65)	// == Equal to, > Greater than
			System.out.println("Congratulation ,You got a distinction and you got " + mark + " marks........");
		else if (mark < 65 & 60 <= mark) 	// < Less than, <= Less than or equal to
			System.out.println("Congratulation ,You got a First class and you got " + mark + " marks........");
		else if (mark < 60  & mark >= 50)
			System.out.println("You got a Second class and you got " + mark + " marks........");
		else if (50 > mark & mark >= 40)	// > Greater than, >= Greater than or equal to
			System.out.println("You got a Third class and you got " + mark + " marks........");
		else 
			System.out.println("You are failed and you got " + mark + " marks........");
		}
		else
			System.out.println("Please give the valid mark...............");
	}
}

Output :
 
..............Relational operators.................
Congratulation ,You got a distinction and you got 70 marks........