小喵 🐈 says to YSITD
public class HW2 { private static int getBytesByClassName(String className) { return Class.forName(className).newInstance().BYTES; } public static void main(String[] args) { String[] dataTypes = new String[]{ "Double", "Float", "Integer", "Short", "Character", "Byte" }; for (String dataType: dataTypes) { int bytes = getBytesByClassName(dataType), bits = bytes * 8; System.out.println("Size of \"%s\" is %d byte(s) = %d bits.\n", dataType, bytes, bits); } } }