Some point on learning Java

本文介绍了Java中接口的使用,包括关键字Interface如何实现多态、接口中变量的特点以及如何通过接口使多个源文件共享常量。此外,还讲解了Java中的异常处理机制,包括所有异常类的基类Throwable及其用法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.
              
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值