I’m using abstract class to have some constants on the same place and also to avoid class instancing. But I get a warning about adding a constructor: “Add a private constructor to hide the implicit public one.”
Abstract class is not the one to be instanced in Java and this warning seems to be misleading.
In case #1 a warning is placed on DeviceConfig
, while in case #2 a waring is moved to Timeouts
// case-1
public abstract class DeviceConfig {
public static final String DEVICE_ID = "11";
public static final int PAYMENT = 10;
}
// case-2
public abstract class DeviceConfig {
public static final String DEVICE_ID = "11";
public abstract class Timeouts {
public static final int PAYMENT = 10;
}
}
OS
Windows 10 Pro; 21H2; build 19044.1566; Windows Feature Experience Pack 120.2212.4170.0
IDE
Spring Tool Suite 4; Version: 4.13.0.RELEASE; Build Id: 202112031748
Java
openjdk version “14.0.2” 2020-07-14; OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.2+12); OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.2+12, mixed mode, sharing)