![]() ![]() an extension receives a call: callsReceived++ an extension makes a call: callsMade++ In very rough terms, we might see: import java.lang.* Then, whenever we start a new period of accumulating call statistics, we initialize each array as: callsMade = new int Īt the end of each period of accumulating call statistics, we can print out the stats. So we might declare two arrays: int callsMade There are eight extensions, numbered one through eight, plus the operator’s extension, numbered zero. For example, suppose we are writing code for counting the number of calls received and made by a set of telephone extensions in a small office. In some cases, arrays emerge naturally as a type of accumulator. The answer to this question, like that of all good questions, is "it depends." In this case, the answer depends on what we expect to do with the array once it is initialized.
0 Comments
Leave a Reply. |