Search code examples
javapackagedefaultpmdscoping

How to solve PMD Violation : Use explicit scoping instead of the default package private level


I want to fix my code PMD violation:

Use explicit scoping instead of the default package private level

It appears on these places in my code:

File saveFile = new File("C:/Upload/"); 
EmployeImplMetier dbE= new EmployeImplMetier();
DepartementImplMetier dbD = new DepartementImplMetier();
FonctionImplMetier dbF = new FonctionImplMetier();
ServiceImplMetier dbS = new ServiceImplMetier();
TypePaiementImplMetier dbT = new TypePaiementImplMetier();
ModePaiementImplMetier dbM = new ModePaiementImplMetier();

I found this LINK before but it didn't help.
Could anyone suggest how to fix it?


Solution

  • These variables should all be declared using the private keyword:

    private File saveFile = new File("C:/Upload/"); 
    

    If you need to access them from outside the class in which they are declared then implement some getXxx methods.