Try using the Stream API in Java


public class Test {
	public static void main(String[] args) {
		List<Integer> sales = new ArrayList<>(Arrays.asList(12, 30, 22, 4, 9));
		for (Integer sale : sales) {
			if (sale % 3 == 0 ) {

		.filter(e -> e % 3 == 0)

		.filter(e -> e % 3 == 0)
		.map(e -> "(" + e + ")")

Result; 1st and 2nd are the same. I put parentheses in the third. I feel like it looks refreshing.



Recommended Posts

Try using the Stream API in Java
Try using the COTOHA API parsing in Java
Try using JSON format API in Java
Try using RocksDB in Java
ChatWork4j for using the ChatWork API in Java
Try using GCP's Cloud Vision API in Java
Java Stream API in 5 minutes
Try global hooking in Java using the JNativeHook library
[java8] To understand the Stream API
I tried using Java8 Stream API
Parsing the COTOHA API in Java
Try Java 8 Stream
Java Stream API
I tried using Elasticsearch API in Java
Data processing using stream API from Java 8
Call the Windows Notification API in Java
Try using the Rails API (zip code)
Try calling the CORBA service in Java 11+
Try various Java Stream API methods (now)
Try using the Emotion API from Android
Try using the Wii remote with Java
Leverage Either for individual exception handling in the Java Stream API
[Java] Stream API / map
Java8 Stream API practice
Zabbix API in Java
[Java] API creation using Jerjey (Jax-rs) in eclipse
Try using Sourcetrail (win version) in Java code
Try using Sourcetrail (macOS version) in Java code
Try accessing the dataset from Java using JZOS
Display "Hello World" in the browser using Java
Display "Hello World" in the browser using Java
[Java] How to operate List using Stream API
[Java] Generate a narrowed list from multiple lists using the Stream API
Try scraping using java [Notes]
Try calling JavaScript in Java
I tried using Google Cloud Vision API in Java
Try implementing the Eratosthenes sieve using the Java standard library
Try developing Spresense in Java (1)
Try functional type in Java! ①
Java Stream API cheat sheet
Use Java lambda expressions outside of the Stream API
[Java] Stream API --Stream termination processing
[Java] Stream API --Stream intermediate processing
[Java] Introduction to Stream API
Use Redis Stream in Java
Try using gRPC in Ruby
Differences in code when using the length system in Java
[Java] Stream API intermediate operation
[Java] Try editing the elements of the Json string using the library
Elasticsearch Operation via REST API using Apache HttpClient in Java
Translate using Microsoft Translator Text API in Java (Japanese → English)
Tips for using Salesforce SOAP and Bulk API in Java
[Java8] Sort int type array in descending order using stream
I was addicted to using Java's Stream API in Scala
How to play MIDI files using the Java Sound API
Guess the character code in Java
Try implementing GraphQL server in Java
Export issues using JIRA's Java API
[Introduction to Java] About Stream API
[Parse] Hit the API using callFunctionInBackground
Specify the java location in eclipse.ini