class or method alias in java

前端 未结 8 1063
青春惊慌失措
青春惊慌失措 2020-12-10 00:31

I have long java class and method names

LONGGGGGGGGGGGGGGGClass.longggggggggggggggggggggggggMethod();

I want to alias it to g.m();

8条回答
  •  轮回少年
    2020-12-10 00:52

    You can use inheritance or encapsulation to wrap the original class.

    class g extends LONGCLASS 
    { 
       void a() { super.loooonnng(); }
    }
    

    or

    class g
    {
       private LONGCLASS lc;
       void a() { lc.loooonnng(); }
    }
    

提交回复
热议问题