Reference
- Java types
- primitive (boolean, byte, short, int, long, char, float, double)
- reference (array, class, and interface) are pointers to these objects
- the void type and null reference
- Array
- a collection of components of the same type
- declarations
- int[] intArray; // delare intArray as an array of int
- creation of array object i.e. allocation of space for its components
- intArray = new int[7]; // allocate space for seven int
- array initializer
- comma-separated list of expressions, enclosed by braces "{" and "}" e.g. intArray = {1,2,3,4,5,6,7};
- accessing component of an array
- intArray[i] where i is in the range of 0 to intArray.length - 1 or else IndexOutOfBoundsException will be thrown
- multidimensional array e.g. int[][] = {{1,2,3},null,{7,8,9}};
- passing Array as argument e.g. public static void main(String[] args) {}
- Class
- an abstraction to model data by their functional properties
- declarations/defination
- define new reference types and describe how they are implemented
- e.g. java.lang.String,
java.util.Arrays
- an array of char is not a String i.e. they are different object (state, behavior, and identity)
- identity and value
- char[] charArray = {'a','d','a'};
String name = "ada";
- behavior
- charArray.length;
name.length();
- String object is immutable
- name.toCharArray(); and provision of StringBuffer class
- Method Overriding and Overloading
- Interface