can I use variable to define length of array in java code example Example 1: length of array in java arr.length; Example 2: set array length java int[] num = new int[5];