当前位置: 首页 > news >正文

单位网站建设朋友圈广告推广文字

单位网站建设,朋友圈广告推广文字,有没有做网站的电话,网站建设时间一.异常 1.概念 程序的非正常执行。高级语言都有异常处理机制(C,Java) 2.一般处理异常的方法 Scanner sc new Scanner(System.in);System.out.println("请输入一个数字:");String s sc.nextLine();if (s.matches("[0-9]&qu…

一.异常

1.概念

程序的非正常执行。高级语言都有异常处理机制(C++,Java)

2.一般处理异常的方法

Scanner sc = new Scanner(System.in);System.out.println("请输入一个数字:");String s = sc.nextLine();if (s.matches("[0-9]+")) {int x = Integer.parseInt(s);System.out.println("输入的数字是:" + x);
} else {System.out.println("程序异常");
}

3.异常方式

Scanner sc = new Scanner(System.in);System.out.println("请输入一个数字:");String s = sc.nextLine();if (s.matches("[0-9]+")) {int x = Integer.parseInt(s);System.out.println("输入的数字是:" + x);
} else {System.out.println("程序异常");
}

4.异常机制

4.1 try

探测代码块是否有异常

try{语句块...
}

4.2 catch

异常捕获

cacth(异常对象 e){}

4.3 finally

有无异常一定执行。异常机制中

在‌Java中,finally块通常用于释放资源、执行清理操作或记录错误。finally块总是会在try或‌catch块之后执行,无论是否出现异常。如果try块中没有出现异常,finally块将在try块之后立即执行;如果try块中出现异常,finally块将紧随catch块执行。

4.4 throws

方法上,声明方法内有异常,异常类型

4.5 throw

抛出异常对象

throw new 异常();

public static void f() throws Exception{int a = 1;int b = 0;if(b==0) throw new Exception("除0异常");
}

5.异常体系

6.自定义异常

package com.ffyc.exception;public class MyException01 extends Exception{public MyException01(String msg){super(msg);}
}class MyException02 extends RuntimeException{public MyException02(String msg){super(msg);}
}class testMyException01{public static void test01() throws MyException01{throw new MyException01("自定义异常继承Exception");}public static void test02(){throw new MyException02("自定义异常继承RuntimeException");}public static void main(String[] args) {test02();try {test01();} catch (MyException01 e) {throw new RuntimeException(e);}}
}

7.图书系统

7.1借书

业务流程,电脑查编号,bookshell找书

package com.ffyc.service;import com.ffyc.entity.Book;//接口
public interface IBookService {Book borrowBook(String title);
}
package com.ffyc.exception;//实现
public class BookException extends RuntimeException{public BookException(String msg){super(msg);}
}
package com.ffyc.entity;import java.util.Date;public class Book {private String title;private String author;private String content;private String status;private Date borrowDate;private double price;public Book(){}public Book(String title, String author, String content, String status, Date borrowDate, double price) {this.title = title;this.author = author;this.content = content;this.status = status;this.borrowDate = borrowDate;this.price = price;}public String getTitle() {return title;}public void setTitle(String title) {this.title = title;}public String getAuthor() {return author;}public void setAuthor(String author) {this.author = author;}public String getContent() {return content;}public void setContent(String content) {this.content = content;}public String getStatus() {return status;}public void setStatus(String status) {this.status = status;}public Date getBorrowDate() {return borrowDate;}public void setBorrowDate(Date borrowDate) {this.borrowDate = borrowDate;}public double getPrice() {return price;}public void setPrice(double price) {this.price = price;}@Overridepublic String toString() {return "Book{" +"title='" + title + '\'' +", author='" + author + '\'' +", content='" + content + '\'' +", status='" + status + '\'' +", borrowDate=" + borrowDate +", price=" + price +'}';}
}
package com.ffyc.service.impl;import com.ffyc.entity.Book;
import com.ffyc.exception.BookException;
import com.ffyc.service.IBookService;import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;public class BookServiceImpl implements IBookService {private List<Book> books = new ArrayList<Book>();{books.add(new Book("西游记","武建军","我的大学生活","在库",null,33.44));}public Book borrowBook(String title)  {Iterator<Book> it = books.iterator();while (it.hasNext()){Book book = it.next();if (book.getTitle().equals(title) && book.getStatus().equals("在库")){return book;}}throw new BookException("图书已借出或丢失");}public static void main(String[] args) {IBookService ibs = new BookServiceImpl();Book book = ibs.borrowBook("西游记");System.out.println(book);}
}

http://www.hkea.cn/news/609328/

相关文章:

  • wordpress仿制建设seo是什么平台
  • 商城网站建设分为几块seo臻系统
  • 网络营销对于个人而言有什么作用seo文章
  • 做书籍封皮的网站今日中国新闻
  • 东莞建设网站电工培训技术学校
  • 深圳聘请做网站人员成都排名seo公司
  • 网站备案之后东莞网站关键词优化公司
  • 多种专业网站建设潍坊网站排名提升
  • 网站投稿系统怎么做网站制作流程是什么
  • 交警网站建设整改百度推广怎么推广
  • 重庆网站建设哪里比较好呢网站下载
  • 网站运行速度慢的原因看b站二十四小时直播间
  • 电商网站开发服务全网营销骗局揭秘
  • 个人网站怎么做互联网营销师培训课程免费
  • 微信网站建设价格网站开发报价方案
  • wordpress utc时间慢8小时大连seo关键词排名
  • 中国建设承包商网站创建软件平台该怎么做
  • 中小企业网站建设费用海外推广服务
  • 企业名称的英文做网站名seo是怎么优化推广的
  • 手机在线建站西安seo服务公司
  • 网站开发有前途吗我也要投放广告
  • 备案 网站名称怎么写crm软件
  • 扁平式网站模板b2b网站推广优化
  • 做外贸网站网络营销咨询服务
  • 江门网站建设方案报价淘宝seo优化怎么做
  • 盘龙城做网站推广网站推广
  • 如何做电子书网站域名站长工具
  • 物联网平台有哪些排名优化外包公司
  • 秦皇岛汽车网站制作数字营销工具
  • 培训教育的网站怎么做东莞做网站的联系电话