only select last 5 elements in array javascript code example Example: last 10 element of array System.out.print(Primes1.get(Primes1.size() - 1) + " ");