为什么下面的代码会抛出UnsupportedOperationException
?
import javafx.beans.property.MapProperty;
import javafx.beans.property.SimpleMapProperty;
public class TestMapProperty {
static MapProperty<String, String> model = new SimpleMapProperty<String, String>();
public static void main(String[] args) {
model.put("blue", "green"); // exception thrown here
}
}
堆栈跟踪:
Exception in thread "main" java.lang.UnsupportedOperationException
at java.util.AbstractMap.put(AbstractMap.java:203)
at javafx.beans.binding.MapExpression.put(MapExpression.java:277)
at TestMapProperty.main(TestMapProperty.java:10)