How might I count the number of int members define

2019-09-21 19:14发布

I have a class that stores a large number of int member variables, each defined as follows:

public final static int int1 = int1value;
public final static int int2 = int2value;
...
public final static int int106 = int106value;

There is a second class that needs to do a loop based on the number of ints in the first class. How would I go about adding a function to the first class to count these member variables?

7条回答
放荡不羁爱自由
2楼-- · 2019-09-21 20:11

It's just 106 "public final static int int1 = int1value" in the first class. No List or Arrays.

Don't bother with a function, just hard code 106 in whatever would uses them. It couldn't make your design any worse.

查看更多
登录 后发表回答