CoderSathi
  • Tutorial
    • Java Tutorial
    • Swing Tutorial
    • JDBC Tutorial
    • Java String Tutorial
    • Servlet and JSP Tutorial
  • Mongo DB
  • AWS
  • DevOps
  • Linux
  • Git
Home > What is > Operators in Java

Java Tutorial

  • Introduction
    • What is Java
    • History Of Java
    • Install Java
    • What is JVM
    • JDK vs JRE vs JVM
    • Java Bytecode
    • OOP vs POP
    • Compile and Run Java
  • Tokens, Expressions and Control Structures
    • Primitive data types
    • Integers
    • Floating Points
    • Characters
    • Booleans
    • User Defined Data Type
    • Declarations
    • Constants
    • Identifiers
    • Literals
    • Type Conversion and Casting
    • Variables
    • Default Variable Initialization
    • Command Line Arguments
    • Arrays of Primitive Types
    • Comment Syntax
    • Garbage Collection
    • Expressions
    • Operators
    • Arithmetic Operator
    • Bitwise and Shift Operator
    • Comparison or Relational Operators
    • Logical Operators
    • Assignment Operators
    • Ternary Operator
    • Increment and Decrement Operator
    • Control Statements
  • OOP Concepts
    • Class and Object
    • Create Class Instance
    • Method
    • Abstraction
    • Encapsulation
    • this keyword
    • Constructor
    • Pass by Value
    • Access Modifier/Control
    • Polymorphism
    • Method Overloading vs Method Overriding
    • Recursion
    • Nested and Inner Class
  • Inheritance and Packaging
    • Inheritance
    • extends Keyword
    • super Keyword
    • Object Class
    • Abstract class
    • Final Class
    • Java Package
    • Interface
  • Handling Error/ Exceptions
    • What is Exception
    • Exception Handling Keywords
    • Common Java Errors
    • User Defined Exception
    • Throwing and re-throwing Exception
    • finally Block
  • Strings
    • Java String Tutorial
  • Threads
    • Introduction
    • Create Thread
    • Thread Lifecycle
    • Thread Priority
    • Thread Synchronization
    • Inner Thread Communication
    • Thread Deadlock
  • IO and Streams
    • java.io Package
    • Files and Directories
    • Byte Stream
    • Character Stream
    • Console Input and Output
    • Serializable and Deserializable
  • Core Packages
    • java.lang Package
    • Math
    • Wrapper Classes
    • java.lang.Number
    • Double
    • Float
    • Integers
    • java.lang.Byte
    • java.lang.Short
    • java.lang.Long
    • java.lang.Character
    • java.lang.Boolean
    • java.util package
    • Vector Class
    • Stack Class
    • Dictionary Class
    • Hashtable
    • Enumeration or Enum
    • Generate Random Number
  • Holding Collection of Data
    • Arrays
    • Map
    • List
    • Set
    • Collection Interface
    • Collections Class
    • ArrayList
    • HashSet
    • TreeSet
    • Comparator
  • Java Bean
    • What is Java Bean
    • Advantages and Disadvantages of Java Bean
    • Java Beans API
    • Introspection
    • Java Bean Properties
    • Bound and Constrained Properties
    • BeanInfo Interface
    • Customizers
    • Java Beans Persistence
    • BeanDescriptor

Operators in Java

Learn the concepts, implementation details, and practical steps with a clean developer-focused walkthrough.

Yuba Raj Kalathoki
By Yuba Raj Kalathoki
Last updated: July 1, 2026 · 3 min read · 0 Comments
Share: in X

Operators in Java are symbols that perform operations on variables and values. They simplify calculations, comparisons, and logical decisions. Let’s explore them with clarity!

Table of Contents

  • Arithmetic Operators
  • Assignment Operators
  • Increment and Decrement Operators
  • Relational (Comparision) Operators
  • Logical Operators
  • Bitwise Operators
  • Conditional (Ternary) Operator
  • Conclusion

Arithmetic Operators

  • Addition (+): Adds two operands.
  • Subtraction (-): Subtracts the second operand from the first operand.
  • Multiplication (*): Multiplies two operands.
  • Division (/): Divides the first operand by the second operand.
  • Modulus (%): Returns the remainder of the division of the first operand by the second operand.

Example:

int result = 15 % 4; // Remainder = 3  
double avg = (10 + 20) / 2.0; // 15.0  

Assignment Operators

  • Assignment (=): Assigns the value on the right to the variable on the left.
  • Compound Assignment Operators (e.g., +=, -=, *=, /=, %=): Combines an arithmetic operation with assignment.

Example:

int x = 5;  
x *= 3; // x becomes 15  

Increment and Decrement Operators

  • Increment (++): Increases the value of a variable by 1.
  • Decrement (–): Decreases the value of a variable by 1.

Example:

int x = 5;  
int a = x++; // a = 5, x becomes 6  
int b = ++x; // b = 7, x becomes 7  

Relational (Comparision) Operators

  • Equal to (==): Checks if two operands are equal.
  • Not equal to (!=): Checks if two operands are not equal.
  • Greater than (>): Checks if the left operand is greater than the right operand.
  • Less than (<): Checks if the left operand is less than the right operand.
  • Greater than or equal to (>=): Checks if the left operand is greater than or equal to the right operand.
  • Less than or equal to (<=): Checks if the left operand is less than or equal to the right operand.

Example:

boolean isEqual = (5 == 5); // true  
boolean isAdult = age >= 18;  

Logical Operators

  • Logical AND (&&): Returns true if both operands are true.
  • Logical OR (||): Returns true if at least one of the operands is true.
  • Logical NOT (!): Reverses the logical state of the operand.

Example:

boolean isEligible = (age > 18) && (hasLicense);  

Bitwise Operators

  • Bitwise AND (&): Performs a bitwise AND operation between two operands.
  • Bitwise OR (|): Performs a bitwise OR operation between two operands.
  • Bitwise XOR (^): Performs a bitwise exclusive OR operation between two operands.
  • Bitwise NOT or Complement (~): Inverts the bits of the operand.
  • Left Shift (<<): Shifts the bits of the left operand to the left by a specified number of positions.
  • Right Shift (>>): Shifts the bits of the left operand to the right by a specified number of positions.
  • Unsigned Right Shift (>>>): Shifts the bits of the left operand to the right by a specified number of positions, filling the leftmost bits with zeros.

Example:

int a = 5; // 0101 in binary  
int b = 3; // 0011  
int c = a & b; // 0001 (1 in decimal)  

Conditional (Ternary) Operator

Ternary Operator (condition ? expr1 : expr2): Evaluates the condition and returns expr1 if true, otherwise returns expr2.

Example:

String status = (marks >= 40) ? "Pass" : "Fail";  

Conclusion

Java operators streamline coding tasks, from math to logic. By understanding their types and rules, you’ll write cleaner, more efficient programs.

Related Posts:

  • Increment and Decrement Operator in Java
  • Arithmetic Operator in Java
  • PEMDAS in Java: Order of Operations Explained with Examples
  • Expressions in Java
  • Ternary Operator in Java
  • Floating point in Java
Tags:javalanguage-fundamentals
Was this article helpful?
← Previous ArticleJava Keywords and Reserved Words
Next Article →Arithmetic Operator in Java

Leave a Comment Cancel reply

You must be logged in to post a comment.

Recent Posts

  • How to implement Passwordless Authentication in Spring Boot: A Step-by-Step Guide
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Fix SSH Agent Forwarding on macOS: The Ultimate Guide for Developers
  • How to Read AWS Secrets Manager in Spring Boot (Step-by-Step)
  • How to Fix “Public Key Retrieval is not allowed” MySQL JDBC Error
CoderSathi

Your go-to resource for Java, Spring Boot, Microservices, AWS, and modern development tutorials.

Linkedin

Quick Links

  • About
  • Contact

Popular Topics

  • Java
  • Spring Boot
  • AWS
  • DevOps
  • MongoDB
  • Linux
  • Git
  • How to
© 2026 CoderSathi. All rights reserved. Privacy Policy · Sitemap