0
我想將超類中已更新的值傳遞給子類,這可能嗎?將更新的超類值傳遞給子類
比如我有:
public class1{
@FXML
ListView <String> list;
// then list gets changed in a method
public void method(){
list.getItems().add("hello");
}
}
而且在不同的類:
public anotherClass extends class1{
public void method(){
System.out.println(list);
// here it seems that the list has not been updated and I get a null value when printing it instead of a list filled with "hello"
}
}
我怎樣才能做到這一點?