所以問題是方法「print()」只能在主void中使用。當我嘗試在「changeAccount()」中使用它時,它說「找不到符號」。僅在主void中查找方法(無法找到符號,符號:方法tulosta(),location:class Object)
public class Main {
public static ArrayList createAccount(ArrayList accountList) {
Account account1 = new Account();
accountList.add(account1);
return accountList;
}
public static int changeAccount(ArrayList accountList) {
accountList.get(0).print();
}
public static void main(String[] args) {
ArrayList<Account> accountList = new ArrayList<>(0);
createAccount(tiliTaulukko);
accountList.get(0).print();
}
}
現在,這裏是從哪裏調用print methos。
public class Account {
public void print(){
}
}
你上哪兒去定義打印?請創建[MCVE](http://stackoverflow.com/help/mcve) – StackFlowed
您可以編輯您的問題以包含完整的錯誤信息嗎? – azurefrog
參數tiliTaulukko代表什麼?我沒有發現它在任何地方初始化。 –