First page Back Continue Last page Graphics
Java Arrays and Strings
In Java arrays and strings are objects
Thus, you can create new ones with new:
- int[] A = new int[5];
- int A[] = new int[5]; // also allowed
- String s = new String(); // empty
Initializing syntax is also allowed:
- double readings[] = {3.01, -44.2, 0.0012};
- String myString = "A brand new string";
Java allows familiar syntax to access array elements, for example: A[i]
But not for strings: myString.charAt(i)