3.21. Array Elements as Actual Parameters

Array elements, like other variables, can store values of primitive data types or references to objects. In the latter case it means they can also be arrays, that is, array of arrays (see Section 4.1, p. 104). If an array element is of a primitive data type, then its data value is passed, and if it is a reference to an object, then the reference value is passed.

Example 3.6. Array Elements as Primitive Data Values
 public class FindMinimum { public static void main(String[] args) { int[] dataSeq = {6,4,8,2,1}; int minValue = dataSeq[0]; for (int index = 1; index < dataSeq.length; ++index) minValue = minimum(minValue, dataSeq[index]); // (1) System.out.println("Minimum value: " + minValue); } public static ...

Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.