Skip to content

Instantly share code, notes, and snippets.

@ozuma
Created April 4, 2023 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozuma/c534604ff5d9ae74a58cb7a3985df126 to your computer and use it in GitHub Desktop.
Save ozuma/c534604ff5d9ae74a58cb7a3985df126 to your computer and use it in GitHub Desktop.
String, Arrays, stream, startsWith
import java.util.Arrays;
import java.util.stream.Stream;
public class stringStreamTest {
public static void main(String[] args) {
String[] arr = { "NYC", "Mexico", "BeiJing", "New Delhi", "Tokyo" };
Stream<String> stream = Arrays.asList(arr).stream();
stream.filter(s -> s.startsWith("N"))
.forEach(System.out::println);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment