Comprehend
- The method name and return type are mandatory in a method
declaration. Even though you are not required to specify a modifier in
a method declaration, the default modifier is assigned to the method,
if you don’t declare one.
- A static variable belongs to the class and not to a
particular instance of the class, and therefore is initialized when the
class is loaded, and before the class is instantiated.
- Because a static method belongs to a class and not to a
particular instance of the class, it cannot access the nonstatic
methods and variables of the class in which it is defined.
- An instance of an inner class can only exist in an instance
of the outer class, and has direct access to all the instance variables
and methods of the outer instance.
- If you make a super call or a this call, it must be in the
beginning of a constructor. That means you can make either a super call
or a this call, but not both.
Look Out
- The variable-length parameters list must appear last in the
parentheses of a method and it consists of a data type, three dots, and
a name, in that order.
- A Java class cannot inherit from more than one class, but it can inherit from one class and one or more interfaces.
- The class that inherits from an interface must provide
implementation for all the methods that are declared in the interface
if the class is not abstract.
- An interface can extend another interface but it cannot implement another interface or a class.
Memorize
- If you do not provide any constructor for a class you write, the
compiler provides the default constructor for that class. If you write
at least one constructor for the class, the compiler provides no
constructor.
- If you don not make a this or a super call in the beginning of a constructor, the compiler places a super() call there.
- You use the keyword extends to write a derived class that
inherits from a parent class, and use the keyword implements to write a
class that inherits from an interface.
- The methods in an interface are inherently public and
abstract, and the variables in the interface are inherently public,
final, and static.
|
|
| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
---|
29 | 30 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|
常用链接
留言簿(1)
随笔分类(5)
随笔档案(13)
相册
Blog Roll
找到我
搜索
积分与排名
最新评论
阅读排行榜
评论排行榜
|
|