Java has several assignment operators that are used to assign values to variables. The basic assignment operator in Java is the equal sign (=), which assigns the value on the right side of the operator to the variable on the left side. Here are some examples:
int x = 10; double y = 20.5; String name = "John Doe";
Aside from the basic assignment operator, Java also has a set of compound assignment operators that allow you to perform an operation and an assignment in a single statement. Here are some of the most commonly used compound assignment operators in Java:
int x = 10; x += 5; // x is now 15
int x = 10; x -= 5; // x is now 5
int x = 10; x *= 5; // x is now 50
int x = 10; x /= 5; // x is now 2
int x = 10; x %= 3; // x is now 1
These are some of the most commonly used assignment operators in Java