public class LengthConversion {
public static final String M_TO_CM = "meter to centimeter";
public static final String M_TO_MM = "meter to millimeter";
public static final String M_TO_DM = "meter to decimeter";
public static final String KM_TO_M = "kilometer to meter";
public static final String INCH_TO_M = "inch to meter";
public static final String FOOT_TO_M = "foot to meter";
public static final String ASM_TO_M = "angstrom to meter";
public static final String FM_TO_M = "fermi to meter";
public static final String MILE_TO_KM = "mile to kilometer";}
I am adding these string to the ArrayList one by one by .add() function. Is there another way?
Maybe you need an enum:
public enum LengthConversion {
M_TO_CM("meter to centimeter"),
M_TO_MM("meter to millimeter"),
M_TO_DM("meter to decimeter"),
KM_TO_M("kilometer to meter"),
INCH_TO_M("inch to meter"),
FOOT_TO_M("foot to meter"),
ASM_TO_M("angstrom to meter"),
FM_TO_M("fermi to meter"),
MILE_TO_KM("mile to kilometer");
public final String conversion;
LengthConversion(String conversion) {
this.conversion = conversion;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.