`
- 浏览:
23928 次
- 性别:
- 来自:
深圳
-
Java Notes: Classes, Methods, and Interface
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.
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
- **Apex Components**: These are components that are directly tied to Apex classes and methods. Understanding how to use these components effectively is crucial for creating visually appealing and ...
21.5 A USER INTERFACE FOR UNDOING AND REDOING 711 21.6 DISCUSSION 712 21.7 BIBLIOGRAPHICAL NOTES 715 EXERCISES 715 Chapter 22: How to find the classes 719 22.1 STUDYING A REQUIREMENTS DOCUMENT 720 ...
Chapter 10: Utility and Exception Classes CStrings Constructing CString Objects CString Operators CStrings and String Resources Comparing Strings Searching CStrings Extracting the Contents of ...
Deprecated Python modules, functions and methods asynchat asyncore dbm distutils grp importlib os re ssl tkinter venv Deprecated functions and types of the C API Deprecated Build Options ...
Legal Notices API, Language, and VM Specs Features Guides Release Notes Tool Docs Tutorials and Training JavaTM SE 6 Platform at a Glance This document covers the JavaTM Platform, Standard Edition...
Scoping Namespaces Nested Classes Nonmember, Static Member, and Global Functions Local Variables Static and Global Variables Classes Doing Work in Constructors Default Constructors Explicit ...
Putting a great looking site together takes a lot of work, and most Java developers are more interested in creating a great looking object interface than a user interface. JavaServer Pages (JSP) ...
RELEASE NOTES: README.txt,v 1.5 2003/02/22 06:21:57 russcoon Exp $_______________________________________________________________________________0.3.0 pre2OVERVIEW: ...structuring of inline constructor ...
Methods and properties of the TempDataDictionary class have been improved to better handle the case when items are flagged for removal from the dictionary. Support for validation in the IDataErrorInfo...
9.3. Basic Methods 9.3.1. The current date 9.3.2. Zend_Date by Example 9.3.2.1. Ouput a Date 9.3.2.2. Setting a Date 9.3.2.3. Adding and Subtracting Dates 9.3.2.4. Comparation of dates 9.4. ...
- Release notes - Midware - Known problems - Special thanks Legal issues: ------------- Copyright (C) 1997-2016 by Fran鏾is PIETTE Rue de Grady 24, 4053 Embourg, Belgium SSL implementation ...
Delphi 7.1 Update Release Notes=======================================================This file contains important supplemental and late-breakinginformation that may not appear in the main ...
3.2. Removed Deprecated Packages and Methods .................................................... 17 3.3. Java 8 (as well as 6 and 7) .....................................................................
3.2. Removed Deprecated Packages and Methods .................................................... 17 3.3. Java 8 (as well as 6 and 7) .....................................................................