In Java, can the static and abstract keywords be used together?

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
KalamyQ
Posts: 16
Joined: Wed Jul 13, 2022 10:59 am
Has thanked: 3 times

In Java, can the static and abstract keywords be used together?

Post by KalamyQ »

When I understand that static and final combinations can be used together, I learned that static and abstract or final and abstract combinations are not permitted in Java while reading this https://www.scaler.com/topics/abstract-keyword-in-java/. However, I have seen the following code elsewhere.

Code: Select all

public class Enclosing {

    private static int x = 1;

    public static abstract class StaticNested {

        public abstract void run();
    }
  }

Could someone kindly explain the principle and practical applications of this scenario?

Post Reply

Return to “Programming”