chapter 7 arrays

chapter 7 arrays - Arrays are objects. Created using the...

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

View Full Document Right Arrow Icon
Arrays are objects. Created using the new operator. Arrays are not primitive data types. Once created, all values of strings are set to null and int types are 0. Int[] scores = new int [10]; Student[] asuStud = new Student[60000]; Scores[2] = 85; instantiating index 2 if the array. asuStud[1] = new Student(“Jill”, 3.15, 16); (name, gpa, num of courses) Enlarging the number of students without losing the original students. Student[] asu Stud2 = new Student[70000]; For(int i=0; i<asuStud.length; i++) { asuStud2[i] = asuStud[i]; } Instantiating of arrays are 2 processes. New and instantiating. Default value for booleans is false. Default for characters are 0. Private char [] charArray; (instantiation of an array in a class) Public Char Collection (int size) { charArray = new char [size]; } static – belongs to the class, will not be used outside the class. Public int[] myMethod(int a) { } int[] b = object.myMethod(x[6]); (calling myMethod) Each object stored in an array must be instantiated SEPARATELY. Int[][] a = new int [row][column];
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/18/2011 for the course CSE 110 taught by Professor Kim during the Fall '08 term at ASU.

Page1 / 3

chapter 7 arrays - Arrays are objects. Created using the...

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

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