Java Basic Operatorsjava
In Java, operators are symbols that are used to perform operations on variables and values. There are several types of operators in Java, including:
- Arithmetic operators: These operators are used to perform arithmetic operations such as addition, subtraction, multiplication, and division.
%: remainder (modulus)
- Comparison operators: These operators are used to compare two values and return a boolean result.
==: equal to
!=: not equal to
> : greater than
<: less than
>=: greater than or equal to
<=: less than or equal to
- Logical operators: These operators are used to perform logical operations such as AND, OR, and NOT.
- Assignment operators: These operators are used to assign a value to a variable.
+=: addition assignment
-=: subtraction assignment
*=: multiplication assignment
/=: division assignment
%=: remainder assignment
- Increment and decrement operators: These operators are used to increment or decrement a value by 1.
Here is an example of how to use some of these operators in Java:
int x = 10; int y = 20; int z = x + y; // z is 30 int a = x - y; // a is -10 int b = x * y; // b is 200 int c = y / x; // c is 2 int d = y % x; // d is 0 boolean e = x == y; // e is false boolean f = x != y; // f is true boolean g = x > y; // g is false boolean h = x < y; // h is true x += y; // x is 30 y -= x; // y is -10 z *= x; // z is 900 a /= y; // a is -2 b %= d; // b is 0 x++; // x is 31 y--; // y is -11
Other Article on Tag java
- - after and before in java date
- - am pm java date format
- - apk minecraft java edition
- - as been blocked by CORS policy Response to preflight request doesn't pass access control check It does not have HTTP ok status
- - bubble sort in java
- - Can I compile and run a spring boot jar from inside another spring boot application
- - convert java date to localdate
- - design patterns in java
- - encrypt by java and decrypt by node
- - exception handling in java