How to add attributes Dynamically for java object?

前端 未结 4 409
清歌不尽
清歌不尽 2020-12-15 01:27

Having Student Class.

Class Student{
    String _name;
    ....
    ....

    public Student(){
    }
}

is there any possibility to add dyn

4条回答
  •  庸人自扰
    2020-12-15 02:20

    You could get into bytecode manipulation but that way madness lies (especially for the programmer who has to maintain the code).

    Store attributes in a Map instead.

提交回复
热议问题