Users Pricing

forum

Home Forums Example of Overrinding static method in java – MindStick

Example of Overrinding static method in java

Anonymous User 2283 10 Oct 2014

i know that we cannot override static methods in java. I read here why:

but can someone explain the following code:

    class A
    {
        public static void a()
        {
            System.out.println("A.a()");
        }
    }  
 
    class B extends A
    {
        public static void a()
        {
            System.out.println("B.a()");
        }
    }

how was I able to override function a() in class B? why did it work here or am I missing something.


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md