Iterate an Enumeration in Java 8
问题 Is it possible to iterate an Enumeration by using Lambda Expression? What will be the Lambda representation of the following code snippet: Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces(); while (nets.hasMoreElements()) { NetworkInterface networkInterface = nets.nextElement(); } I didn't find any stream within it. 回答1: In case you don’t like the fact that Collections.list(Enumeration) copies the entire contents into a (temporary) list before the iteration starts,