Java Operators

0.0(0)
studied byStudied by 0 people
0.0(0)
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/21

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:01 AM on 1/31/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

22 Terms

1
New cards

Operators

Allow us to perform operations on variables and values.

2
New cards

Arithmetic Operators
Assignment Operators
Compound Assignment Operators
Comparison Operators
Logical Operators
Increment and Decrement Operators

Java operator categories

3
New cards

Arithmetic Operators

Used for mathematical calculations.

4
New cards

Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)
Modulus (%)

Arithmetic Operators is used for mathematical calculations, including _______, _______, _______, _______, and _______.

5
New cards
public class Main{
	public static void main(String[] args){
		int a = 12;
		int b = 90;
		
		System.out.println("Addition: " + (a + b));
		System.out.println("Modulus: " + (a % b));
	}
}

OUTPUT:
10

Example of Arithmetic Operators

6
New cards

Assignment Operators

Used to assign values to variables. The = operator is the basic assignment operator.

7
New cards
public class Main{
	public static void main{
	int x = 5;
	x += 4; //Equivalent to x=x+4

	System.out.print(x);
	}
}

OUTPUT:
9

Example of Compound Assignment Operators

8
New cards

Comparison Operators

Used to compare values, returning a boolean result (true or false).

9
New cards

Equal to (==)
Not equal to (-=)
Greater than (>)
Less than (<)
Greater than or Equal to (>=)
Less than pr Equal to (<=)

Comparison operators that are used are ______, _______, _______, ______, _______, _______.

10
New cards
public class Main{
	public static void main(String[] args){
	int age = 29;

	System.out.print(age < 29);	

	}
}

OUTPUT:
False

Example of comparison operators

11
New cards

Logical Operators

Used to combine multiple conditions, returning a boolean result.

12
New cards

AND (&&)
OR (||)
NOT (!)

Logical operator uses different operator including _______, _______, and _______.

13
New cards

AND (&&)

Returns true if both conditions are true.

14
New cards

OR (||)

Returns true if at least one condition is true.

15
New cards

NOT (!)

Inverts the boolean value.

16
New cards
public class main{
	public static void main(String[] args){
	int allowance = 2000;
	boolean ily = true;

	System.out.print(allowance == 2000 && ily);
	}
}

OUTPUT:
true

Example of logical operators

17
New cards

Increment and Decrement Operators

Used to increase or decrease a variable by 1.

18
New cards

Prefix (++x)

Increments the value before use in an expression

19
New cards

Postfix (x++)

Increments the value after use in an expression.

20
New cards
public class Main{
	public static void main(String[] args){
	int x = 3;
	
	System.out.println(--x);
	System.out.println(x++);
	}
}

OUTPUT:
2
2 (count 3)

Example of increment and decrement

21
New cards

Compound Assignment Operator

Shorthand way to update a variable's value by performing an operation on it like addition or multiplication and then assigning the result back to that same variable.

22
New cards
public class Main{
	public static void main(String[] args){
	int x = 3;
	
	System.out.println("Initial Value: " + x);
	}
}

OUTPUT:
Initial Value: 3

Example of Assignment Operator.