zoukankan      html  css  js  c++  java
  • 为什么接口在设计时所有的方法一般都要抛异常?

    为什么接口并没有实现具体的函数却还要抛异常出来呢?

           这是因为在设计接口时并不知道实现接口的方法是不是会抛出异常。如果在设计接口方法时不抛出异常,就会造成实现的类即使需要抛异常也无法抛弃的情况,因此,在实际开发中,一般都要在接口的方法抛出异常。

     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 }
  • 相关阅读:
    1086. Tree Traversals Again (25)
    1094. The Largest Generation (25)
    1076. Forwards on Weibo (30)
    1083. List Grades (25)
    1082. Read Number in Chinese (25)
    【七夕特辑】程序员表白网页合集
    flex布局
    Nodejs进阶:基于express+multer的文件上传
    Git 和 SVN 之间的五个基本区别
    React通用后台管理系统
  • 原文地址:https://www.cnblogs.com/xiaoqiqistudy/p/11206826.html
Copyright © 2011-2022 走看看