Here you can find the source of filterInstances(Stream
public static <T, U> Stream<T> filterInstances(Stream<T> stream, Class<U> clazz)
//package com.java2s; //License from project: Apache License import java.util.stream.Stream; public class Main { public static <T, U> Stream<T> filterInstances(Stream<T> stream, Class<U> clazz) { return stream.filter(clazz::isInstance); } }/* www. j av a 2s . c o m*/