Menu
Topics Index
...
`

Java Operators | Ternary Operator

Java Operators are symbols those are useful to perform certain operations. In other words, Java Operators are objects that perform specific actions on particular values and find the result. They help in performing operations. There are different types of Java operators like Java ternary operator, arithmetic operator, Increment and Decrement operator, Modulus operator, boolean logical operator, relational operator, Short circuit logical operator, assignment operator and bitwise operator. All these classifications of Java operators can be used in different types of operations.

For example take the expression, 24+14*50. Where +, * are the Java operators and 24, 14, 50 are the operands in Java. According to the operation, the no.of operands will be vary for every Java operator. There are two operands for addition operator and there is only one operand for unary operator; but for Java ternary operator, there are three operands. In Java operators, ternary operator is the only operator which contains three operands.

Java Operators, Java Operators | Ternary Operator

Java ternary operator is also known as Conditional Operator. This Java ternary operator is useful for evaluating boolean expressions. The main purpose of this ternary operator is to determine which value should be assign to the variable. Java ternary operator uses the symbol '? :'. It completely works like a if-else statement. Boolean expression is the first operand in this ternary operator. If the condition is true then second operand value will be assigned to the variable otherwise the third operand value will be assigned. So, Java ternary operator is useful for replacing if_then_else statements.

Java ternary operator, Java Operators | Ternary Operator

In this chapter, we can also learn about Arithmetic operator, Increment and Decrement operator, Modulus operator, Boolean logical operator, Relational operator, Short circuit logical operator, Assignment operator, Operator Precedence And Associativity in detail at below.


In this Java Operators section, we'll go into detail about:
4.1 Operators In Java
  • Java Operators are special symbols that perform specific operations on operands and find the result. e.g., +, -, *, >, <=, !. These Java operators help in performing operations like ...Read More

4.2 Java Arithmetic Operators
  • Arithmetic Operators help in performing the algebra operations like addition, subtraction, multiplication and division. The list of all supported Arithmetic Operators In Java are...Read More

4.3 Basic Arithmetic Operators In Java
  • Basic Arithmetic Operators are sub group of Java Arithmetic Operators which include only addition, subtraction, multiplication and division. Here you have Basic Arithmetic ...Read More

4.4 Increment And Decrement Operators In Java
  • Increment Operator increases its operand by 1. The Decrement Operator decreases its operand by 1. Instead of x = x + 1; we could do x++; Increment And Decrement ...Read More

4.5 Modulus Operator In Java
  • Java has one important arithmetical operator you may not be familiar with, %, also known as the modulus operator.The modulus operator, % returns the remainder of a ...Read More

4.6 Arithmetic Compound Assignment Operators In Java
  • Arithmetic Compound Assignment Operators In Java are used to combine an arithmetic operation with an assignment operation. e.g., marks += 5; instead of marks = ...Read More

4.7 Relational Operators In Java
  • The relational operators determine the relationship between two operands. e.g., 3 is greater than 2, 25 is less than 30. The following six relational operators are supported ...Read More

4.8 Boolean Logical Operators In Java
  • Boolean logical operators operate only on boolean operands. These operators combine one or two boolean values to form a new boolean depending upon the operation. Logical...Read More

4.9 Short Circuit Logical Operators In Java
  • Java provides two boolean operators boolean AND and boolean OR which are not provided by the other language and these operators are known as Short-Circuit logical ...Read More

4.10 Assignment Operator In Java
  • Assignment operator is used to assign a value of an expression to a variable. Usual assignment operator we see is ' = '. e.g., a = 5;. Like other languages Java also uses assignment ...Read More

4.11 Java Ternary Operator
  • Java Ternary operator can be used to replace certain types of if-then-else statements. It is called Java ternary operator because it uses three operands. The syntax for Java ternary operator...Read More

4.12 Java Operator Precedence And Associativity
  • Operator precedence plays an important role if there are multiple operators involved in an expression. E.g., int a = 7 * 3 + 24 / 3 - 5; In java * and / have more precedence compared to...Read More

4.13 Temperature Conversion Program In Java
  • Learn Temperature Conversion Program In Java This program converts the temperature in Fahrenheit to Celsius. The formula used is C = 5.0 * (F - 32.0) / 9.0 . The following program...Read More

Dependent Topics : 3. Variables 

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App