I don’t understand as well what do you mean by “custom list”.
But in your code, it seems you want to retrieve only the first and the last integer from the List.
If you want to perform only this two operations, a Queue would be better than an ArrayList in term of performance.
Obviously, if you have to deal with a limited number of data, the solutions are practically equivalent.
1
solved Custom List in java