Java Reference
In-Depth Information
data.add(); // OK but not useful
The modified add method must be declared as
public void add(double... xs)
The ș symbol indicates that the method can receive any number of double
values. The xs parameter is actually a double[] array that contains all values
that were passed to the method. The method implementation traverses the
parameter array and processes the values:
for (x : xs)
sum = sum + x;
R ANDOM F ACT 7.1: An Early Internet Worm
In November 1988, a graduate student at Cornell University launched a virus
program that infected about 6,000 computers connected to the Internet across the
United States. Tens of thousands of computer users were unable to read their
e-mail or otherwise use their computers. All major universities and many high-tech
companies were affected. (The Internet was much smaller then than it is now.)
The particular kind of virus used in this attack is called a worm. The virus program
crawled from one computer on the Internet to the next. The entire program is quite
complex; its major parts are explained in [ 2 ]. However, one of the methods used in
the attack is of interest here. The worm would attempt to connect to finger , a
program in the UNIX operating system for finding information on a user who has
an account on a particular computer on the network. Like many programs in
UNIX, finger was written in the C language. C does not have array lists, only
arrays, and when you construct an array in C, as in Java, you have to make up your
mind how many elements you need. To store the user name to be looked up (say, ), the finger program allocated an array of 512
characters, under the assumption that nobody would ever provide such a long
input. Unfortunately, C, unlike Java, does not check that an array index is less than
the length of the array. If you write into an array, using an index that is too large,
you simply overwrite memory locations that belong to some other objects. In some
Search WWH ::

Custom Search