Operator in Java Program-2

Operator in Java Program – 2

Operator is very important for all languages. Operator can calculate, check, assign, increase and decrease the value of variable. So operator is heart of java program. I give simple example of operator in java.

“ans = (x>y) ? x : y;

In this example ans, x and y are variable;

= (assignment) and > (Relational) are operators. “

So we can easily understand the import of operator in java program language. In this blog we will discuss on Relational [ >, <, >=, <=, ==, != ] and Conditional[ (condition) ? true : false ] operators.

  1. Relational operator

>, <, >=, <=, ==,!=are relational operator in all java programming languages. These operators help for check relation on two variables. We are familiar with >, <, >=, <=, ==,!= relational operator in C and Cpp. They are working same as C and Cpp.


  1. Conditional Operator

This operator is also famous as ternary or three way operator in java program.  Using of this operator we can check two or more variable like if we want find maximum number from two numbers. So we can use this operator. Symbol of this operator is [(condition)? true part: false part]. If condition is true that time true part will execute otherwise false part will execute.



Program in Relational Operator ans Conditional Operator:

class op2


public static void main(String args[])


int x = 67;

int y = 55;

int max;

max = (x>y) ? x : y;

System.out.println(“Max = ” + max);




Max =67


Video available on YouTube.




If you have problem on this blog, you can directly comment or subscribe on website.


Free Program Download | Free Video


806total visits,2visits today


Hello, I am Maddy a Java blogger, trainer and developer

Related articles

Comments are closed.