Immutable Objects in Java


Immutable objects are thread-safe by design, as their state cannot change after construction.

Source Code

public final class ImmutableClass {
    private final int value;

    public ImmutableClass(int value) {
        this.value = value;
    }

    public int getValue() {
        return value;
    }
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments