Java Database Spring Microservices CICD Examples
Java Database Spring Microservices CICD Examples
- Lambda Expressions
(a, b) -> a + b;
- Stream API
- Functional Interfaces
@FunctionalInterface
- Optional Class
name.ifPresent(System.out::println);
- Date-Time API
System.out.println(now);
Example:
Lambda expressions allow you to pass a block of code as a parameter to a method or store it in a
variable.
Functional interfaces are interfaces with only one abstract method.
Example:
interface MathOperation {
System.out.println(add.operate(5, 3));
Example:
lock.lock();
try {
// Critical section
} finally {
lock.unlock();
In Java, the String class is immutable and stored in the String Pool.
Example:
System.out.println(str2); // Java 8
The static keyword is used to declare variables, methods, blocks, or inner classes that belong to the
class rather than instances.
Example:
class Counter {
count++;
Counter.increment();
System.out.println(Counter.count); // 1
Global variables are declared at the class level and shared by all instances, whereas instance
Example:
class Car {
The Java Memory Model (JMM) defines how threads interact with memory.
It involves the heap (for storing objects), stack (for method execution), and method area (for class
metadata).
Collections in Java include interfaces like List, Set, and Map. HashMap stores key-value pairs.
Example:
class Person {
String name;
@Override
@Override
return name.hashCode();
private Singleton() {}
if (instance == null) {
return instance;