In your code,
int l= arr[0].length;
in this line, arr[0] represents the value in array named as arr at 0th index.
Hence length function can be used in this way to find the length of value stored in array at 0th index.
int l = arr[0].length();
In order to find out the length of array, try this code:
int l = arr.length;
solved Error while getting length of command line arguments in java [closed]