lundi 13 août 2018

How to initialize field in subclass inherited from base class Java [duplicate]

I have a few final fields which I have declared in a base class, I want to initialize those fields in a subclass? Is this possible? Note the fields in the base class are declared final, so some trickery may be required

class Base
{
   public final String a;
   public final String b;
}

class Sub
{
   public Sub(String a, String b)
   {
      a = a;
      b = b;
   }
}

Something like this? Any help would be appreciated

Aucun commentaire:

Enregistrer un commentaire