If the user types:
java myProg firstParam secondParam
CHAP. 5] PROGRAMMING IN JAVA 69
the program myProg can retrieve the String ???firstParam??? from args[0], and the String ???secondParam??? from
args[1].
JAVA OPERATORS
Operators are symbols in a language that stand for built-in functions. Java has a great many operators and,
since this chapter will only serve to introduce the Java language, we will not discuss them all. Here are the
operators we will discuss:
By assignment, we mean taking the value on the right side of the equal sign (sometimes called RS) and giving
that value to the variable on the left side of the equal sign (sometimes called LS). If the value of k is 5, after the
following statement is executed, the value of c will also be 5. Likewise, the value of k will remain 5 after execution:
c = k;
The arithmetic operators perform their expected functions. For example, if the value of a is 3, and the value
of b is 5, after the following statement executes the value of x will be 15:
x = a * b;
In contrast to some other languages, Java has no operator for exponentiation. If a programmer wants to raise
a number to some power, the program must perform the exponentiation either by repeatedly multiplying, or by
using the pow() method of the Math class which is part of the built-in Java library.
Pages:
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196