Java 8: Streaming A String 📎
public static void main(String[] args) {
"hey duke".chars().forEach(c -> System.out.println((char)c));
}
The parallel version does not preserve the order (and comes with additional overhead):
public static void main(String[] args) {
"hey duke".chars().parallel().forEach(c -> System.out.println((char) c));
}
Enjoy Java 8!