我想要獲得一個類生成的值,並讓其他類使用它並實時更新它。這是我做過什麼與生成數類:如何編輯另一個類的值?
public Integer red(int red){
this.red = red;
return red;
}
然後我叫
private int red;
在其他類我做:
int r = gui.red(); //Gui is the name of the original class
但它告訴我詮釋着適用於它。如果我將它設置爲0,它始終保持爲零,而其他班級無法改變它。我怎樣才能使這項工作正確?
爲什麼你不像'public int red()'返回一個原始的int? – user3437460