The accepted answer is correct. I will provide additional information for interested readers.
ObservableList is an interface and, as such, does not have the size property. ListExpression is an abstract class that implements an ObservableList and adds ReadOnlyIntegerProperty size as well as ReadOnlyBooleanProperty empty properties. This class is the base class for the whole tree of inheritance of the list property classes.
Most users will not want to subclass abstract classes in the tree itself, so we will look at the specific implementation provided:
ListExpression (abstract) - ReadOnlyListProperty (abstract) - ListProperty (abstract) - ListPropertyBase (abstract) - SimpleListProperty - ReadOnlyListWrapper
SimpleListProperty , as the name implies, has a simple list property - ObservableList , wrapped in Property . This is a parallel to other SimpleXxxProperty s. It also has a subclass of ReadOnlyListWrapper for handling read-only, read, and write requirements. It can be built from an ObservableList :
SimpleListProperty<String> list = new SimpleListProperty<>(FXCollections.observableArrayList()); IntegerProperty intProperty = new SimpleIntegerProperty(); intProperty.bind(list.sizeProperty());
Users who need the benefits of this class (only when using an ObservableList ) and decide to use it do not need static Bindings#size .
source share