Java “self” (static) reference

前端 未结 4 1205
感动是毒
感动是毒 2021-02-20 14:04

I am looking for a \"self\" reference to the current class in JAVA in a static context manner like in PHP Scope Resolution Operator?

Solution: Break out of scope? BEWARE

4条回答
  •  忘掉有多难
    2021-02-20 14:31

    You don't need to use any of those. What I find convenient to use is:
    //Logger

    private static final Logger logger = LoggerFactory.getLogger(CreateEmployeeRecord.class or this.class);

    Do it in every class that needs logging, and change class name in bracket to corresponding class wherever it's being used.

提交回复
热议问题