您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)


Content Index

Content Page # 45

Numeric expressions

There are several operators provided by Java for numeric expressions.

Examples of numeric expressions include the following:

2 + 2

age + 1

25 / 5

2.5 * 4

15 % 4

The implementation of the most common numeric operators in Java are as follows:

Operation

Java symbol

example

evaluates to

addition

+

2 + 2

4

subtraction

-

5 - 2

3

multiplication

*

2.5 * 4

10.0

division

/

5 / 2

2.5

modulus
(integer division)

%

15 % 10

1

As can be seen, some of these operations can be used with, and result in either whole numbers or floating point numbers.

You should explore the range of numeric expressions as presented in Deitel & Deitel.

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg