Java code TIPS

Lambda knowledge

Main functional interface

Interface name Method Overview
Function<T,R> R apply(T t) Argument T,Return value R
Consumer<T> void accept(T t) Argument T,No return value
Predicate<T> boolean test(T t) Argument T,Return value boolean
Supplier<T> T get() No arguments,Return value T
UnaryOperator<T> T apply(T t) Argument T,Return value T
BinaryOperator<T> T apply(T t1, T t2) 2 arguments T,Return value R
BiFunction<T,U,R> R apply(T t, U u) Arguments T and U,Return value R

Intermediate operation

Method name Overview
filter Elements that match the conditions
distinct Elements without duplication
limit Specified number of elements
skip Elements excluding the specified number
map Elements converted by some processing
sorted sort

Termination operation

Return type Method name Overview Similar
boolean anyMatch Did it match any of the elements allMatch
R collect Result of variable reduction operation
long count Number of elements
Optional<T> findAny Either element findFirst
void forEach Processing for elements that do not return a return value
Optional<T> max Maximum element min
T reduce Cumulative processing result

List related

Sort and combine"", (all,s) -> all + "\r\n" + s);

String.join("\r\n", list);

Unique sort

		List<String> list = new ArrayList<String>();
		list.add("A1:100");, s2) -> {

			int ret = s1.substring(s1.length() -3).compareTo(s2.substring(s2.length() -3));
			if(ret == 0) {
				return s1.compareTo(s2);
			return ret * -1;


Output the contents of List


Serial number creation

Recommended Posts

Java code TIPS
Java tips, tips
Java Tips
Script Java code
Java sample code 02
Java sample code 03
Java sample code 04
Java sample code 01
Java character code
Java tips --StaticUtility class modifier
Digital signature sample code (JAVA)
Java parallelization code sample collection
Java test code method collection
[Windows] Java code is garbled
Java in Visual Studio Code
Java tips --Spring execution Summary
Write Java8-like code in Java8
[Java] Tips for writing source
Code Java from Emacs with Eclim
Java Spring environment in vs Code
Java High Level REST Client Tips
Java 15 implementation and VS Code preferences
Java 9 new features and sample code
[Java] Boilerplate code elimination using Lombok
Java build with mac vs code
Arbitrary string creation code by Java
Execute packaged Java code with commands
Java source code reading java.lang.Math class
Introducing Java tips GreenMail to Junit5
[Java] Boilerplate code elimination using Lombok 2
Java development environment (Mac, VS Code)
[Android] Convert Android Java code to Kotlin
Sample code using Minio from Java
Basic structure of Java source code
Java learning (0)
Studying Java ―― 3
[Java] array
Java protected
[Java] Annotation
Prepare Java development environment with VS Code
[Java] Module
Java array
Studying Java ―― 9
Java scratch scratch
Java methods
Java method
java (constructor)
Java array
[Java] ArrayDeque
java (override)
java (method)
Java Day 2018
Java string
java (array)
Java static
Java serialization
java beginner 4
JAVA paid
Studying Java ―― 4