Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

What does it mean, how can I fix it?

it whole class is like this:

package com.xxxxxxxxxxx.app.xxxx;

public class HeartBeat
{
    private static final Logger LOG = LoggerFactory.getLogger( HeartBeat.class );
    private final File heartBeatFile;


    public HeartBeat( File heartBeatFile )
    {
        this.heartBeatFile = heartBeatFile;
    }


    public void beat()
    {
        try
        {
            FileUtils.writeStringToFile( heartBeatFile, String.valueOf( System.currentTimeMillis() ) );
        }
        catch( IOException e )
        {
            LOG.error( "Error while writing heart beat log", e );
        }
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
292 views
Welcome To Ask or Share your Answers For Others

1 Answer

IDEA is referring to package-private visibility.

A class may be declared with the modifier public, in which case that class is visible to all classes everywhere. If a class has no modifier (the default, also known as package-private), it is visible only within its own package

For more information, see Controlling Access to Members of a Class.

You can solve the problem by removing public keyword from the class (if the class is not intended to be used outside the package), or by using the class from a different package.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...