Here you can find the source of getLast(Iterator
public static <T> T getLast(Iterator<T> iterator)
//package com.java2s; /*/*from www .ja v a2 s. c om*/ * Copyright (c) Microsoft. All rights reserved. * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ import java.util.Iterator; public class Main { public static <T> T getLast(Iterator<T> iterator) { T last = null; while (iterator.hasNext()) { last = iterator.next(); } return last; } }