爲什麼下面的代碼拋出UnsupportedOperationException
?UnsupportedOperationException在使用javafx SimpleMapProperty
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)
如果您發佈了完整的異常和堆棧跟蹤,這將有所幫助。 –