Stream Skip

Skip is used to skip the result

package org.wesome.java8;

import java.util.Arrays;
import java.util.List;

class Apple {
    public static void main(String args[]) {
        final int SKIP = 2;
        List<String> apples = Arrays.asList("Macintosh", "Fuji", "Gala", "Jonagold");
        System.out.println("*---------------------------Traditional method---------------------------*");
        for (int i = SKIP; i < apples.size(); i++) {
            System.out.println(apples.get(i));
        }

        System.out.println("*---------------------------Peak---------------------------*");
        apples.stream().skip(SKIP).forEach(System.out::println);
    }
}

 

follow us on