24h購物| | PChome| 登入
2012-04-17 16:19:47| 人氣673| 回應0 | 上一篇 | 下一篇

[JAVA] 上課考的定義

推薦 0 收藏 0 轉貼0 訂閱站台

考這些東西真的很 ... 有些定義我覺得不錯, 所以我就打出來了



Chapter 4 Defining Classes I
  • Constructor: A constructor is a variety of method that is called when an object of the class is created using new. Constructors are used to initialize objects.
  • Signature: The signature of a method consists of the method name and the list of types for parameters that  are listed in the heading of the method name.
  • Overloading: Within one class, you can have two (or more) definitions of a single method name. This is called overloading the method name.
    (利用不同的 Signature 來做 Overloading, 但是有一個特例, 不能 Overload Operators in Java)
  • Encapsulation: Encapsulation means that the data and the actions are combined into a single item (in our case, a class object) and the details of the implementation are hidden.
    (這個"封藏"概念, 與 Information Hiding(資訊隱藏) 可說是一體的兩面)
  • The this Parameter: Within a method definition, you can use the keyword this as a name for the calling object. If an instance variable or another method in the class is used without any calling object, then this is understood to be the calling object.



Chapter 5 Defining Classes II
  • immutable: A class that contains no methods that change any of the data in an object of the class is called an immutable class, and object of the class are called immutable objects.
    (簡單的說, 不會有任何的方法可以修改這物件的任何資料, String 就是)
  • mutable: A class the contains public mutator methods or other public methods, such as input methods, that can change the data in an object of the  class is called a mutable class, and objects of the class are called mutable objects.
  • static import:
    可將靜態方法引入, 可在程式碼中少打幾個字
  • Wrapper class: provide a class type corresponding to each of the primitive types.
    • Automatic Boxing and Unboxing
    • Static Methods in Wrapper Classes
  • Static Variable: A static variable belongs to the class as a whole. All objects of the class can read and change the static variable. Static variables should normally be private, unless they happen to be defined constants.
    (有一部份的功能可用來溝通物件與物件之間)
  • Static Method: A static method is one that can be used without a calling object. With a static method, you normally use the class name in place of a calling object.
    (在Method中, 不可使用 this parameter, nonstatic method, instance variable)


Chapter 6 Arrays
  • 我不知道哪個定義比較重要, 但我覺得有幾個重點必須說明
  • 必須了解 Arrays.length 與 String.length() 這兩者的差別
    一個是 instance variable, 另一個則是 method
  • 必須了解陣列的宣告方式
    Base_Type[] Array_Name = new Base_Type[Length];
  • 可變數量的參數(Variable Number of Parameters)
    Type ... Array_Name
  • For-Each Loop for Arrays 的使用
    for(Array_Base_Type Variable : Array_Name)


Chapter 7 Inheritance
  • Inheritance provides a tool for code reuse by deriving one class from another. The derived class automatically inherits the features of the old(base) class and may add features as well.
    (可提供程式碼的再使用率)
  • A derived class object inherits the instance variable, static variables, and public methods of the base class, and more generally, has the type of every one of its ancestor classes.
  • Package Access: If you do not place any of the modifiers public, private or protected before an instance variable or method definition, then the instance variable or method is said to have package access.
  • The protected Modifier: If a method or instance variable is modified by protected, then it can be accessed by name inside its own class definition, by name inside any class derived from it, and by name in the definition of any class in the same package
  • Overriding a Method Definition: A derived class inherits methods that belong to the base class. However, if a derived class requires a different definition for an inherited method, the method may be redefined in the derived class. This is called overriding the method definition.
    (final method 不可被覆寫, 在此我也疑問 static method 貌似也不能被覆寫, 屬於 hide)

台長: Morris
人氣(673) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: [學習]Java |
此分類下一篇:[JAVA] foreach 的陷阱
此分類上一篇:[JAVA][作業][Lab4] Inheritance

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文