when trying to declare a new ObservableList
:
ObservableList<Account> userAccounts = new FXCollections.observableArrayList();
I am getting an error at observableArrayList();
which says:
cannot find symbol, symbol: class
observableArrayList
, location: classFXCollections
.
Here are my import statements
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
And here is my method
public ObservableList<Account> getUsersAccounts(int memberID) {
ObservableList<Account> userAccounts = new FXCollections.observableArrayList();
try {
Statement stmt = conn.createStatement();
String sql = "SELECT * FROM account WHERE member_id='" + memberID + "'";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()) {
Account account = new Account(rs.getInt("member_id"), rs.getString("account_type"), rs.getDouble("balance"));
userAccounts.add(account);
}
} catch (SQLException ex) {
Logger.getLogger(JDBCManager.class.getName()).log(Level.SEVERE, null, ex);
}
return userAccounts;
}
What am I missing, why can't I declare a new ObservableList
?
new
. – GoblinobservableArrayList()
is a static method, not a class. – Discophilenew
for a static methods so use:ObservableList<Account> userAccounts = FXCollections.observableArrayList();
– Naphtholnew
keyword is used when you call a constructor. – Discophile