// 迭代 // public static<T> Stream<T> iterate(final T seed, final UnaryOperator<T> f) //遍历前10个偶数 Stream.iterate(0, t -> t + 2).limit(10).forEach(System.out::println);
// 生成 // public static<T> Stream<T> generate(Supplier<T> s) Stream.generate(Math::random).limit(10).forEach(System.out::println);
@Test publicvoidtest5(){ Boy boy = null; boy = new Boy(); boy = new Boy(new Girl("苍老师")); String girlName = getGirlName2(boy); System.out.println(girlName); } }