Retornar o último elemento
Retorne o último elemento de um array ou o último caractere de uma string. Se a entrada estiver vazia, retorne null.
Exemplos
Program.lastItem(new Integer[]{0, 4, 19, 34, 50, -9, 2}) ➞ 2
Program.lastItem("The quick brown fox jumped over the lazy dog") ➞ 'g'
Program.lastItem(new Integer[0]) ➞ nullNotas
- Os arrays e as strings podem ter tamanhos diferentes.
- Retorne
nullse a entrada estiver vazia.