為什么接口並沒有實現具體的函數卻還要拋異常出來呢?
這是因為在設計接口時並不知道實現接口的方法是不是會拋出異常。如果在設計接口方法時不拋出異常,就會造成實現的類即使需要拋異常也無法拋棄的情況,因此,在實際開發中,一般都要在接口的方法拋出異常。
1 package org.west.dao.bill; 2 3 import org.west.pojo.Bill; 4 import java.sql.Connection; 5 import java.util.List; 6 7 public interface BillDao { 8 //增加訂單 9 public int add(Connection connection, Bill bill) throws Exception; 10 11 //通過條件獲取供應商列表-模糊查詢-getBillList 12 public List<Bill> getBillList(Connection connection,Bill bill) throws Exception; 13 14 //通過delId 刪除Bill 15 public int deleteBillById(Connection connection,String delId) throws Exception; 16 17 //通過billId獲取Bill 18 public Bill getBillById(Connection connection,String di) throws Exception; 19 20 //修改訂單 21 public int modify(Connection connection,Bill bill)throws Exception; 22 23 //根據供應商ID查詢訂單數量 24 public int getBillCountByProvideId(Connection connection,String providerId) throws Exception; 25 26 }