What does “Can be package local” mean? (IDEA Inspection)

前端 未结 5 1459
太阳男子
太阳男子 2020-12-14 14:08

I used IntelliJ for \"Inspect Code\", and one of its results is:

  Problem synopsis      Can be package local (at line 18(public class HeartBeat))

5条回答
  •  猫巷女王i
    2020-12-14 14:32

    Your HeartBeat class isn't used anywhere outside of package com.xxxxxxxxxxx.app.xxxx. In this case you can declare the class 'protected' or 'private' to be more precise in your access.

    If you do not intend to use this class outside of this package, you should change the class declaration. If you intend to use this class outside this package, leave it and the warning will go away.

    E.g.:

    protected class HeartBeat {
        ...
    }
    

提交回复
热议问题