Linear Data Structures 1.2

Linear Data Structures 1.2 - Arrays in Java...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Last Updated: 12-01-17 9:52 AM CSE 2011 Prof. J. Elder - 6 - Arrays in Java (java.util.Arrays) For an array of length n , the index bounds are 0 to n-1 . Java arrays are homogeneous all array components must be of the same (object or primitive) type. but, an array of an object type can contain objects of any respective subtype An array is itself an object. it is allocated dynamically by means of new it is automatically deallocated when no longer referred to When an array is first created, all values are automatically initialized with 0, for an array of int[] or double[] type false, for a boolean[] array null, for an array of objects Example [ common error –unallocated arrays] int [] numbers; numbers[2] = 100;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Last Updated: 12-01-17 9:52 AM CSE 2011 Prof. J. Elder - 7 - Arrays in Java The length of any array object can be accessed through its instance variable ‘ length ’. the cells of an array
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

Linear Data Structures 1.2 - Arrays in Java...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online