1.By using Keyword Interface, java allow you to fully utilize the "One interface, multiple methods" aspect
of polymorphism.
2.Variables can be declared in an interface, but they are implicitly public,
static, and final.
Since a large program is typically held in a number of separate source files,
there needs to be a convenient way to make these constants available to each file.
In java, interface variables offer a solution.
3. Exception
In java, all exception classes are derived from a class called Throwable.
4. Using Java's Type wrappers to convert numeric strings
5. Enumeration
The key is to remember that each of the enumeration constants is an object of the
class in which it is defined.
6. Static import
By following import whith the keyword static ,an import statement can be used to import
the static members of a class or interface.
Note: 1. when an interface is declaired as public, it should reside in a file with the same name.
2. since the superclass of all exceptions is Throwable, to catch all possible exceptions, catch Throwable.
If you want to catch exceptions of both a superclass type and a subclass type, put the subclass first in the catch sequence.
of polymorphism.
2.Variables can be declared in an interface, but they are implicitly public,
static, and final.
Since a large program is typically held in a number of separate source files,
there needs to be a convenient way to make these constants available to each file.
In java, interface variables offer a solution.
3. Exception
In java, all exception classes are derived from a class called Throwable.
4. Using Java's Type wrappers to convert numeric strings
5. Enumeration
The key is to remember that each of the enumeration constants is an object of the
class in which it is defined.
6. Static import
By following import whith the keyword static ,an import statement can be used to import
the static members of a class or interface.
Note: 1. when an interface is declaired as public, it should reside in a file with the same name.
2. since the superclass of all exceptions is Throwable, to catch all possible exceptions, catch Throwable.
If you want to catch exceptions of both a superclass type and a subclass type, put the subclass first in the catch sequence.
本文介绍了Java中接口的使用,包括关键字Interface如何实现多态、接口中变量的特点以及如何通过接口使多个源文件共享常量。此外,还讲解了Java中的异常处理机制,包括所有异常类的基类Throwable及其用法。
3073

被折叠的 条评论
为什么被折叠?



