I create an interface with constants and a final-array that contains these constants:
interface SozKonstants{ public static final String ONE="one"; public static final String TWO="two"; public static final String THRE="thre"; public static final String[] NUMBER={ONE,TWO,THRE}; }
But the elementary assignment works, the compiler does not swear that "an attempt was made to change the final variable"
public class SomeClass{ public static void main(String[] args){ System.out.println(SozKonstants.NUMBER[1]); SozKonstants.NUMBER[1]="ten"; System.out.println(SozKonstants.NUMBER[1]); } }
I can not understand where was wrong and how to make sure that the compiler does not miss the replacement values in the array.