小编mci*_*hak的帖子

使用关键字throws来声明抛出运行时异常

对我来说,这些代码

static int faktorial (int n) throws ArithmeticException {
  if ((n < 0) || (n > 31)) { 
    throw new ArithmeticException();
  } 
  if (n > 1) {
    return n * faktorial(n - 1);
  } 
  else {
    return 1;
  }    
}
Run Code Online (Sandbox Code Playgroud)

没有相同的代码

throws ArithmeticException
Run Code Online (Sandbox Code Playgroud)

当我使用以下代码时,请执行相同的操作:

public static void main(String[] args) {
  try {
    int n;
    Scanner sc = new Scanner(System.in);  

    System.out.print("Insert integer number: ");        
    n = sc.nextInt();         
    System.out.println(n + "! = " + faktorial(n));
  }
  catch (InputMismatchException e) {
    System.out.println("Not an …
Run Code Online (Sandbox Code Playgroud)

java exception-handling

5
推荐指数
1
解决办法
844
查看次数

Chrome和Firefox中box-shadow的不同行为

我想创建这样的东西:

结果

我准备了以下测试页面:

p {
  display: inline;
  background-color: yellow;
  box-shadow: 10px 0px 0px red, -10px 0px 0px red;
}
Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>

<head>
</head>

<body>

  <p>Here will be a text. Here will be a text. Here will be a text. Here will be a text. Here will be a text. Here will be a text. Here will be a text. Here will be a text. Here will be a text. Here will be a text. Here will be a text. Here …
Run Code Online (Sandbox Code Playgroud)

css css3

5
推荐指数
1
解决办法
209
查看次数

标签 统计

css ×1

css3 ×1

exception-handling ×1

java ×1