What are static methods in interfaces introduced in Java 8?
Learn how static methods in Java interfaces work: syntax, rules, why they are not inherited, JDK examples, and the difference from default methods.
2,889 posts about Java: questions with answers, tutorials and articles, newest first.
Learn how static methods in Java interfaces work: syntax, rules, why they are not inherited, JDK examples, and the difference from default methods.
Default methods give interfaces method bodies so APIs can evolve without breaking implementations. See syntax, the diamond rules and examples.
Method references use the :: operator as a shorthand for lambdas that call one existing method. See the four kinds with runnable examples.
Use Optional as a return type, transform it with map and flatMap, and unwrap with orElseGet or orElseThrow instead of get().
Optional is a container that holds a value or nothing. See how to create, read and transform it, and when not to use it.
collect() is the terminal Java Streams operation that gathers elements into a List, Set, Map, string or grouping using a Collector. See examples and pitfalls.
map() is one-to-one; flatMap() expands each element into a stream and flattens the result. See examples with lists, Optional and mapMulti().
Java streams process data in a lazy pipeline of operations without changing the source. Learn collectors, primitive streams, parallel streams and pitfalls.
The main Java 8 features with working examples: lambdas, streams, default methods, Optional and the new date and time API.
Step-by-step JNI guide: declare a native method, generate the header, implement it in C, build the library, and compare it with the Foreign Function and Memory API.
JNI connects Java to C and C++ through native methods and shared libraries. This guide has a full example, safety rules, and notes on newer JDK native access restrictions.
fork() starts work in parallel and join() waits for the result. Compare Java Fork/Join with POSIX fork() and waitpid(), with working code.
A synchronized method locks the entire method on one monitor, while a synchronized block limits the lock to selected code. See examples, a comparison table and best practice.
volatile gives visibility and ordering for one variable, while synchronized adds mutual exclusion for a block. Compare them with working examples.
Java concurrency spans threads, synchronized, locks, atomics and executors, plus virtual threads since Java 21. See how they fit together with examples.
The Java Memory Model sets the rules for how threads see each other's writes. Learn happens-before, volatile, synchronized and safe publication.
Log4j 2 and Logback are the main Java logging frameworks. Compare them, see working configs with SLF4J, and learn security and best-practice points.
SLF4J is a logging facade that separates your log calls from the backend. Learn the Logger API, providers, bridges, and how it works with Logback.
Use SLF4J with Logback or Log4j 2, one logger per class, parameterized messages and an external config. Includes java.util.logging and best practices.
Spring Cloud solves discovery, configuration, routing, resilience and tracing for Spring Boot microservices. Learn which components are current and when to skip it.