Chinaunix首页 | 论坛 | 博客
  • 博客访问: 329909
  • 博文数量: 130
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 554
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-19 19:24
文章分类

全部博文(130)

文章存档

2016年(31)

2015年(16)

2014年(13)

2013年(70)

分类: Android平台

2016-03-07 15:18:35


点击(此处)折叠或打开

  1. java exception :
  2. 异常处理通过try {} catch {} 模块来处理
  3. try
  4. {
  5.    //Protected code
  6. }catch(ExceptionType1 e1)
  7. {
  8.    //Catch block
  9. }catch(ExceptionType2 e2)
  10. {
  11.    //Catch block
  12. }catch(ExceptionType3 e3)
  13. {
  14.    //Catch block
  15. }finally
  16. {
  17.    //The finally block always executes.
  18. }

  19. throw and throws keyword:
  20. throw 创建并抛出一个异常实例
  21. throws 又在函数声明的时候,代表这个函数
  22. 可能会抛出的异常类型
  23.  public void withdraw(double amount) throws RemoteException,
  24.                               InsufficientFundsException
  25.    {
  26.        // Method implementation
  27.    }
  28.    
  29. finally 在try 和catch语句后,最后都会执行后面的语句

  30. java的多态:
  31.     在编译的时候,只是查找当前class是否存在该方法的声明,实际运行的时候是调用运行对象的
  32.     定义的方法,override方法体现了多态,在override方法中想调用父类的方法可以通过super关键字调用
  33.     Here, at compile time, the compiler used mailCheck() in Employee to validate this statement.
  34.     At run time, however, the JVM invokes mailCheck() in the Salary class.

  35.     This behavior is referred to as virtual method invocation,
  36.     and the methods are referred to as virtual methods.
  37.     All methods in Java behave in this manner,
  38.     whereby an overridden method is invoked at run time,
  39.     no matter what data type the reference is that was used in the source code at compile time.
  40.     

  41. A class which contains the abstract keyword in its declaration is known as abstract class.

  42. Abstract classes may or may not contain abstract methods ie., methods with out body ( public void get(); )

  43. But, if a class have at least one abstract method, then the class must be declared abstract.

  44. If a class is declared abstract it cannot be instantiated.

  45. To use an abstract class you have to inherit it from another class, provide implementations to the abstract methods in it.

  46. If you inherit an abstract class you have to provide implementations to all the abstract methods in it.


  47. 接口:
  48. An interface is similar to a class in the following ways:

  49. An interface can contain any number of methods.

  50. An interface is written in a file with a .java extension, with the name of the interface matching the name of the file.

  51. The byte code of an interface appears in a .class file.

  52. Interfaces appear in packages, and their corresponding bytecode file must be in a directory structure that matches the package name.

  53. However, an interface is different from a class in several ways, including:

  54. You cannot instantiate an interface.

  55. An interface does not contain any constructors.

  56. All of the methods in an interface are abstract.

  57. An interface cannot contain instance fields. The only fields that can appear in an interface must be declared both static and final.

  58. An interface is not extended by a class; it is implemented by a class.

  59. An interface can extend multiple interfaces.

阅读(973) | 评论(0) | 转发(0) |
0

上一篇:Android 用户初始化流程

下一篇:iptables

给主人留下些什么吧!~~