java return first and last element of array of string code example Example: java last element in array arrayName[arrayName.length() - 1];