In my work assignment , one of the java class returns the string messages according to the inetger number which been given as input to its method. There are around 300 string messages right now inside that class. The integer value varies from range 100 to 200, 200 to 300, 300 to 400, 400-500 and it's goes on. The Class has one method getMesg(int number) inwhich I have coded as below. Is there any other way to implement the same functionality with performance improvement??
For a start there is no need (that I can see) for the if-statements, or for the else-if-statements. The case statement on its own should be sufficient.
for details on Internationalization. This should provide a handy technique where your strings are stored in a text file and easily extracted using a key-value technique where your key is your number 100, 200, etc and your value is the string you wish to return. This will allow you to change your messages without having to recompile the code.
Of particular interest in the tutorial mentioned above would be the Isolating Locale-Specific Data, Formatting and Working with Text sections.