1. 一个class只能extends一个class,却可以implements多个interface

  2. 在interface中声明的variable默认是public static final

  3. Try-catch, checked/unchecked exception

https://www3.cs.stonybrook.edu/~pfodor/courses/cse114.html

Java常见概念错误

1.对于Error来说,它是由系统产生的,很少发生,而且我们对它做不了任何事(除了告知用户和终止程序外)。
2.我们唯一要注意的是exception,对于exception来说,我们要么explicitly catch他们,要么我们把它们handle掉。
3.除了RuntimeException,其他exception都要被explicitly try-catch,
4.RuntimeException还有error(两者合称为unchecked exception)不需要被try-catch
5.RuntimeException要么直接正确地改掉,要么用if statement套住
6.finally 是为了cleanup memory,无论有没有exception
7.如果我们能自己解决这个exception(例如用if解决),就不要throw!,因为要花时间创造一个exception object在memory里

相关文章:

  • 2021-05-25
  • 2021-12-03
  • 2021-06-11
  • 2021-08-11
  • 2022-02-27
  • 2021-10-12
  • 2021-08-22
猜你喜欢
  • 2021-08-09
  • 2021-08-17
  • 2021-10-06
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案