Download presentation
Presentation is loading. Please wait.
Published byLiana Sumadi Modified over 6 years ago
1
Arrays of Objects // The following does NOT create memory for
// objects, it only makes a blueprint array Employee [] employees = new Employee [MAXEMP]; // Must create memory and call constructor for // each single member of aray of objects for (i = 0; i < MAXEMP; i++) employees[i] = new Employee();
2
Passing Arrays to Methods
Pass Array Name into Method int [] intArray = new int[100]; loadArray(intArray); Accept into Method as an Array with No Set Size void loadArray( int [] passedArray ) Changes to Array in Method *will* Update Original Array
3
public static void main(String [] args)
{ final int ASIZE = 5; int [] intArray= new int[ASIZE]; for(int i = 0; i < ASIZE; i++) intArray[i] = i; System.out.println( intArray[0]); changeZero(intArray); } static void changeZero(int [] passedArray) passedArray[0] = 1000;
4
Initializing Arrays char [] cArray3 = {'a', 'b', 'c'};
int [] iArray = {1, 2, 3, 4}; double [] dArray = {3.4, 5.67e4};
5
Two Dimensional Arrays
char [][] cArray = new char[10][20]; int [][] iArray = new int[100][50]; cArray[0][0] = ‘a’; cArray[0][1] = ‘b’; cArray[9][19] = ‘x’; iArray[0][0] = 99; iArray[1][5] = 135; iArray[99][49] = 0;
6
Employee Class Review Create a Class Employee Employee.java
Employee Attributes (data members) Constructor Accessor Methods Mutator Methods tryEmployee.java (Client Test Program)
7
Final Exam 2 Hours 200 Points 35% of Grade Must Take to Pass Course
8
Need to Know for Final Everything Through Exam 2 Plus: Arrays Methods
Classes Constructors Accessor Methods Mutator Methods
9
Final Exam 200 Points Total – 35% of Final Grade
90 points Matching or Short Answer or Multiple Choice (Terminology, Operators, JAVA Basics) 30 Points Program Output 80 Points Programming (Full Programs)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.