I have 50 lines of code
private const CODE = 0;
private const DESC = 1;
// ...
private const TRIM = 19; // instead of 24
private const SMURF = 35; // instead of 25
private const DOG = 31; // instead of 26
// ...
private const CAT = 49;
private const AMOUNT = 50;
As you can see, numbers are not sorted right. I'd like to rewrite them so that I get the following instead:
private const CODE = 0;
private const DESC = 1;
// ...
private const TRIM = 24;
private const SMURF = 25;
private const DOG = 26;
// ...
private const CAT = 49;
private const AMOUNT = 50;
enum { CODE, DESC, .... , TRIM, SMURF, DOG, ... , CAT, AMOUNT }
This is AFAIK the preferred way of setting up a set of related constants. I am a little hazy on the Java aspect though. But I can vaguely remember Java also having enums to do the same. You need to check out stackoverflow for this. Both for Java and C/CPP.