课程: Java Essential Training: Syntax and Structure

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Arithmetic operators

Arithmetic operators

- [Angie] Java provides five operators for basic math calculations. These operators work with any numeric values, which includes the data types byte, short, int, long, float, and double. The plus symbol is used to add two numeric values together. The plus symbol has an overloaded use in Java. It's also used to append a value to a string, which is text. The other operators only work with numeric values. The minus symbol is used to subtract a value from another. The asterisk symbol is used to multiply two values together. The slash is used to divide one value by another, and the percent symbol is called the modulo operator, and is used to compute the remainder of dividing one value by another. For example, 5 modulo 2 would be 1, because that is the remainder of dividing 5 by 2.

内容