3 Introduction to Operators and Expression in Java

3.1 INTRODUCTION

For performing different kinds of operations, various types of operators are required. An operator denotes an operation to be performed on some data that generates some value. For example, a plus operator (+) on 3 and 4 generates 7 (3 + 4 = 7). Here, 3 and 4 are called operands.

Java is rich in built-in operators. The four main classes of operators are arithmetic, relational, logical and bitwise.

Apart from these, there are many other operators. A list of operators provided by Java is given in Table 3.1.

Operator Symbolic Representation
Arithmetic +, -, /, *, %
Logical &&, ||, !
Relational >, <,<=,>=, = =, ! =
Assignment =
Increment ++
Decrement --
Comma

Get Java Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.