Java Operators
Java Operators
Java Operators
Binary Operators
Operator Use Description
Examples . . .
iValue += 8; is the same as iValue = iValue + 8;
jValue %= 5; is the same as jValue = jValue % 5;
Shortcut Assignment Examples
char1 + char2
+ Concatenates characters and strings
string1 + string 2
Examples . . .
• char cValue = ‘s’;
Declares a character variable cValue and assigns
character s to it.
• String c1Value = “red”, c2Value = “bird”;
Declares string variables c1Value and c2Value assigning
strings “red” and “bird” to them respectively.
• System.out.println(c1Value + c2Value + cValue);
Outputs string redbirds to the PC monitor, which is the
concatenation of all three variables.
Creating Complex Assignments