Basic Java 3
Basic Java 3
Objectives
char[] s;
Point[] p;
Create space for a reference
An array is an object; it is created with new
Creating Arrays
Object Array
public Point[] createArray(){
Point[] p; Execution Stack
p = new Point[10]; Heap Memory
for(int i =0;i<26;i++){
p[i]=new Point(I,I+1); Point[] Point
x
} y
return p; p x
createArray this y
}
main x
y
Initialize Arrays
Arrays of arrays
int twoDim[][] = new int[4][];
twoDim[0]=new int[5];
twoDim[1]=new int[5];
Example
public void println(int i);
public void println(float f);
public void println(String s);