Let's be fair with Java. The language has seen quite a few enhancements since Java 8 release, 3 years ago, and very recently on Java 9, both on API and syntax. Now using the new stuff...
Loop a string:
String str = "hello";
str.chars() // Produces a stream of integers... yeah, that's odd
.mapToObj(i -> (char) i) // Now we have a stream of chars
.forEach(System.out::println);
Loop a collection:
List<String> list = List.of("a", "b");
list.forEach(System.out::println);
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Let's be fair with Java. The language has seen quite a few enhancements since Java 8 release, 3 years ago, and very recently on Java 9, both on API and syntax. Now using the new stuff...
Loop a string:
Loop a collection: