I have a test class with fields containing test content. It looks like this:
class Test { public static String s1 = " ... long string ... "; public static String s2 = " ... long string ... "; public static String s3 = " ... long string ... "; }
Now I would like to use these fields in a loop, so I wrote an extra array
public static String[] a = {s1, s2, s3};
This structure works fine, but a little ugly, because every time I add or remove a field, I also modify the array.
The only solution to restructure my code without manually manipulating the array is to write everything in the array at once:
class Test { public static String[] a = {" ... long string ... ", " ... long string ... ", " ... long string ... "}; }
As you can see, this makes the code unreadable, especially when we have to deal with s> 10 long lines.
What could be a better structure?
source share