how to get last element of arraylist java code example Example: java last element in array arrayName[arrayName.length() - 1];