There are 3 main classes of operators: arithmetic, comparison, logical
You should learn what they are and have a fairly good idea of precedence.
Precendence means which operators are done first. In math we just use BEDMAS to figure this out.
Look at the operator precedence page.
What is printed out by this statement?
System.out.print("The total is " + 5 + 3);
It will print "The total is 53"
Brackets are generally evaluated before other operators. This is the = sign. It takes everything on the right hand side and puts the results into a variable on the left side. You need to know the increment and decrement operators: a++ and a-- , as well as ++a and --a. You also need to know the shortcut operators:Types of Brackets
Arithmetic operators
Comparison Operators
> < >= <= != ==
<= . =<
will not work if (lives == 0) exitGame();
if (name.equals("Lars")) ...
not if (name == "Lars") ...
Use .equals() for comparing any two objects.Logical Operators
if (date == 29 && month == 2) System.out.println("Leap day!!");
Assignment Operator
It is generally the last thing done.Other Operators
+= -= *= /=
If they are in an expression, ++a is evaluated before other things, a++ is evaluated after other things