Unary Operator Java (-)
Unary Operator is used to negate a value. Negation is converting negative number to positive number and positive number to negative number.
-variable or – value
In the following example value of a is 10 and -a is assigned to b. Value of b becomes -10. Value of c is -20 and -c is assigned to d so value of d become +20; Continue reading
Java Ternary Operator / Java Conditional Operator
The ternary operator is also called conditional operator. It is called ternary as it deals with three variables.
variable = (expression1)? expression2 : expression3 ;
expression1 is evaluated first . If expression1 value is true expression2 value will be assigned to variable .If expression1 value is false expression3 value will be assigned to variable.
In the following example (age>=18) is the condition if the expression is true value “Allowed”is assigned to voting else “Not Allowed” will be assigned to voting Continue reading
While loop repeats group of statements as long as condition is true. Once the condition is false the loop is terminated.
While Statement In Java – Syntax :
} Continue reading