0

I have this declaration

private ObservableList<ObservableList> data;

where ObservableList is import javafx.collections.ObservableList; and class is like this

public interface ObservableList<E> extends List<E>, Observable

So my question is how this implicit declaration of E works. What is E inside E?

Shreyans jain
  • 559
  • 6
  • 18

1 Answers1

1

So my question is how this implicit declaration of E works. What is E inside E?

It doesn't, not really.

The E in this case is the raw type ObservableList; and you shouldn't use raw types.

Raw types are a concession to retain backwards-compatibility with pre-generics code, and shouldn't be used unless you have to interface with code that uses raw types.

In this case, the issue is that if you get an element of data, e.g. data.get(0), that is a raw-typed ObservableList, so you can do things with it that aren't type safe, such as adding elements to the list of the wrong type.

Andy Turner
  • 137,514
  • 11
  • 162
  • 243