Java Exercise 10: Arrays
public class arr01 { public static void main(String[] args) { int m[]; // = int []m; // m = user-defined name (memory space = address of m on heap) // 4 bytes reserved as null on stack m = new int[5]; // Through new, 5 int spaces allocated on heap // m now holds the reference to heap memory for (int i = 0; i < m.length; i++) { m[i] = i * 10; System.out.println("m[" + i + "] = " + m[i]); } } }Covers array declaration, memory allocation with new, stack vs heap memory, and the length property.
