0% found this document useful (0 votes)
2 views3 pages

Java Operators Beginners

Operators in Java are symbols that perform operations on variables and values, including arithmetic, relational, logical, assignment, and increment/decrement operations. They allow for mathematical calculations, comparisons, condition combinations, and value assignments. This document provides beginner-friendly notes on the various types of operators and their usage in Java.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Java Operators Beginners

Operators in Java are symbols that perform operations on variables and values, including arithmetic, relational, logical, assignment, and increment/decrement operations. They allow for mathematical calculations, comparisons, condition combinations, and value assignments. This document provides beginner-friendly notes on the various types of operators and their usage in Java.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Operators in Java - Beginner Friendly Notes

1. What are Operators in Java?

Operators are symbols used to perform operations on variables and values.

In Java, operators help you do actions like addition, comparison, assigning values, and more.

2. Arithmetic Operators

Used to do basic math operations:

+ : Addition

- : Subtraction

* : Multiplication

/ : Division

% : Remainder (Modulus)

Example:

int a = 10, b = 5;

a + b = 15

a-b=5

a * b = 50

a/b=2

a%b=0

3. Relational (Comparison) Operators

Used to compare two values. They return true or false.

== : Equal to

!= : Not equal to

> : Greater than

< : Less than

>= : Greater than or equal to

<= : Less than or equal to

Example:
Operators in Java - Beginner Friendly Notes

int a = 10, b = 5;

a > b -> true

a == b -> false

4. Logical Operators

Used to combine multiple conditions.

&& : AND (true if both conditions are true)

|| : OR (true if at least one is true)

! : NOT (reverses the condition)

Example:

int age = 20;

boolean hasID = true;

if (age >= 18 && hasID) {

System.out.println("You can enter.");

5. Assignment Operators

Used to assign or update values in variables.

= : Assign

+= : Add and assign

-= : Subtract and assign

*= : Multiply and assign

/= : Divide and assign

Example:

int score = 50;

score += 10; // score becomes 60

6. Increment and Decrement Operators


Operators in Java - Beginner Friendly Notes

Used to increase or decrease value by 1.

++ : Increment

-- : Decrement

Example:

int count = 0;

count++; // becomes 1

count--; // back to 0

7. Summary

Operators in Java help in:

- Doing Math: +, -, *, /, %

- Comparing: >, <, ==, !=

- Combining conditions: &&, ||, !

- Assigning values: =, +=, -=

- Increasing/Decreasing: ++, --

Next Topic: Conditional Statements (if, else, switch)

You might also like