ALSTRA
ALSTRA

Reputation: 661

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

Upvotes: 1

Views: 92

Answers (1)

Eran
Eran

Reputation: 393821

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 :

fnlData.get(i).set(indexC,null);

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.

Upvotes: 4

Related Questions