ALSTRA ALSTRA -5 years ago 93
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download