Arrays & Strings

Arrays & Strings

Arrays are dynamically created in the same way as objects:

int table[] = new table[128];

int lookup[] = {1,2,4,8,16,32,64,128};

Arrays have a length field:

for(int i =0; i

table[i] *= 2; // double

Strings are not null terminated arrays of characters:

String a = “Hello”;

String b = “World”;

String message = a + “, ” + b;

Strings are immutable. Use StringBuffer to modify the contents of a String.

Previous slide Next slide Back to the first slide View Graphic Version