我有以下代码在类customerModel
。如何从另一个类customerController
调用此方法?如何将arraylist方法调用到另一个类?
public ArrayList<Customer> search(Customer cust) {
ArrayList<Customer> custs = new ArrayList<Customer>();
Connection connection = GaritsConnectivity.connect();
Tuple<ResultSet, Statement> trs = GaritsConnectivity.read("SELECT * FROM Customer WHERE CustomerID=1", connection);
ResultSet rs = trs.getFirst();
try {
//takes a customer, returns it with the correct ID set
while (rs.next()) {
custs.add(createFromRs(rs));
}
} catch (SQLException ex) {
GaritsConnectivity.manageException("Customer search failure", ex);
}
GaritsConnectivity.doneReading(connection, trs);
return custs;
}
内customerController
类我想创造另一种方法,我可以从CustomerModel
调用搜索方法。
public class customerController....
public boolean search(){
//what goes in here im lost? how can i connect the above search from customerModel to customerController?
}
** **尽快被BADD .... – PermGenError 2013-03-12 10:02:14
来创建此方法属于和使用对象调用该方法的类的对象。 – Meherzad 2013-03-12 10:03:19
如果你已经尝试了很长时间......为什么现在你需要的是尽快? – 2013-03-12 10:03:55