Why is the access to a private field not forbidden?

前端 未结 6 2225
無奈伤痛
無奈伤痛 2020-12-21 02:04

For my study in the university I\'m forced to do some ugly java basics, like working without encapsulation, main method in the same class etc. (I do not want to open a discu

6条回答
  •  甜味超标
    2020-12-21 03:03

    You can write any other static method in the Person class and access the private variables from that method. Main is just a name. Such is life.

提交回复
热议问题