DEV Community

Maria Boldyreva
Maria Boldyreva

Posted on

4 2

Introduction to Java: modifiers cheatsheet

Modifiers in Java still seem tricky to me, so I'll try to put it as short as possible.

Modifiers are words that alter the class / method / variable behavior. The two main types are access and non-access modifiers.

  1. Access modifiers alter visibility:

    • no modifier - the class is visible to its package
    • private - only to the class
    • public - to every class everywhere
    • protected - to the package and its subclasses
  2. Non-access modifiers alter other functionalities:

    • static - makes the declaration class specific, not instance specific. It allows to use the method without an actual instance
    • final - doesn't allow the reference to change
    • abstract - for a method, declares that the method should be overriden in subclasses, for a class, that it cannot be instantiated, only subclassed

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post