Category Java

Unary Operator in Java

The operator that acts on a single operand is called unary operator in Java. A unary operator uses a single variable or literal. For example, to assign two variables with different values containing positive or negative signs, the statements are:…

Operators in Java | Arithmetic Operators

Types of operators in Java

A programmer generally makes a program to perform some operation. For example, we can perform the addition of two numbers just by using + symbol in a program. Here, + is a symbol that performs an operation called addition. Such…

Relational Operators in Java with Example

Relational operators in Java are those operators that are used to perform the comparison between two numeric values or two quantities. These operators determine the relationship between them by comparing operands. Therefore, relational operators are also called comparison operators. For…

Conditional Operator in Java: Ternary Operator

Conditional operator in Java

Conditional operator in Java provides a one-line approach for creating a simple conditional statement. It is often used as a shorthand method for if-else statement. It makes the code much more simple, shorter and readable. The conditional operator (?:) is…

String Constructor in Java with Example

In this tutorial, we will understand the most commonly used string constructor in Java with the help of example programs. In Java, string class supports several types of constructors to create and initialize string objects based on the various types…