3.20. Passing Array References

Arrays are objects in Java (see Section 4.1, p. 100). A review of arrays is recommended before continuing with this section.

The discussion on passing object reference values in the previous section is equally valid for arrays. Method invocation conversions for array types are discussed along with those for other reference types in Section 6.6.

Example 3.5. Passing Arrays
 public class Percolate { public static void main (String[] args) { int[] dataSeq = {6,4,8,2,1}; // Create and initialize an array. // Write array before percolation. for (int i = 0; i < dataSeq.length; ++i) System.out.print(" " + dataSeq[i]); System.out.println(); // Percolate. for (int index = 1; index < dataSeq.length; ++index) if (dataSeq[index-1] ...

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.