Googled for it, found plenty of code. But any of them gave me what I want. I want to make an ordinary array Immutable. I tried this:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class test {
    public static void main(String[] args) {
        final Integer array[];
        List<Integer> temp = new ArrayList<Integer>();
        temp.add(Integer.valueOf(0));
        temp.add(Integer.valueOf(2));
        temp.add(Integer.valueOf(3));
        temp.add(Integer.valueOf(4));
        List<Integer> immutable = Collections.unmodifiableList(temp);
        array = immutable.toArray(new Integer[immutable.size()]);
        for(int i=0; i<array.length; i++)
            System.out.println(array[i]);
        array[0] = 5;
        for(int i=0; i<array.length; i++)
            System.out.println(array[i]);
    }
}
But it doesnt work, I CAN assign a 5 into array[0] ... Is there any way to make this array immutable?
 
     
     
     
    