ALSTRA ALSTRA - 4 months ago 6x
Java Question

Why can't I initialize this List<List<String>>?

Why isn't this possible to do?

private ObservableList<List<String>> fnlData;
fnlData.get(i).get(indexC) = null;

It says:

this happens


fnlData.get(i).get(indexC) is the value of a method call. You can't assign anything to the value of a method call.

You can initialize elements of your Lists with set :


Of course, fnlData.get(i) must be initialized first. And set(indexC,null) will only work if the List returned by fnlData.get(i) already contains at least indexC+1 elements.