Example


\begin{lstlisting}
class ArithmeticOperator {
public static void main(String[] ...
...2;
System.out.println(''number1 % number2 = '' + result);
}
}
\end{lstlisting}

In the above example, all operands used are variables. However, it's not necessary at all. Operands used in arithmetic operators can be literals as well. For example,


\begin{lstlisting}
result = number1 + 5.2;
result = 2.3 + 4.5;
number2 = number1 -2.9;
\end{lstlisting}

The + operator can also be used to concatenate two or more strings. For example


\begin{lstlisting}
class ArithmeticOperator {
public static void main(String[] ...
...esult = start + middle + end;
System.out.println(result);
}
}
\end{lstlisting}

The output from above code can be Talk is cheap. Show me the code. - Linus Torvalds.