- This is entirely appropriateMake the method static, butand you will be fine -- static code must be in order must be compiled in order. Put the loadStrings function before the static code block.
Please note : However - you might be better off simply creating a single, static , "init" method, which is called in your static code block . This will be nameable and unit-testable, unlike your current implementation.
- By the way : your float syntax is off need to be casted properly.
By the way : your float syntax is off, and must to be casted properly.
int i = (int) 1.4f;
To initialize the static variables you can do the following :
- Declare a static init() method, which reads the file and initializes the static variables.
- Create a separate FileReader object in a separate class, or a static inner class, which can be invoked to read in variables , and invoke it FROM your static code block.
- (bad idea) Put the file reading logic inside of your big static code block . this will be very ugly however.