-------Android Training, Java training, look forward to communicating with you! ----------
1. Object-oriented design ideas
Process oriented: It is to take a process as the unit, consider its implementation method , the concern is its function realization .
Object-oriented: it is to consider its attributes (characteristics) and actions (behaviors) in the context of a specific thing .
2. Object-oriented approach to problem-thinking
What are the objects?
What are the characteristics and functions of an object?
The relationship between objects?
3. Classes and objects
3.1, object-oriented programming idea: is trying to make the computer language in the description of things as much as possible with the reality of the real thing in the same.
3.2, classes (Class) and objects (object) are the core concepts of object-oriented methods.
Class: Is a description of the characteristics and behavior of a class of things, is an abstract, conceptual definition. such as: human
Object: An entity that is actually present in the class, also known as an instance (instance)
4.java and object-oriented
object is the core of Java, in Java "Everything is Object".
The class describes the object's properties and behavior, and the class is the object's template, drawing.
An object is an entity that actually exists in a class.
The JDK provides many classes for programmers to use, and programmers can customize classes
Class---(instantiated)-object----(abstract)---> class.
5. Encapsulation Class
For OOP (object-oriented programming):
Encapsulation: The properties and methods of a type of thing are packaged together in a program unit, which is implemented in the form of a class.
Abstraction: Describes the features of an objective object in the Java language. Abstraction focuses on only one topic and the relevant aspects of the current goal, ignoring other unrelated areas
Data abstraction: Abstract the properties and methods of a class.
Encapsulates a class that abstracts related properties and methods from objects of the same type, depending on the application.
6. Default value for member variables in class (when uninitialized)
Byte=0 short=0 int=0 long=0l float=0.0f double=0.0d
Boolean=false char= ' \u0000 ' reference type =null
7.this Keywords
This can be thought of as a variable whose value is a reference to the current object.
When you use the properties of this class in a method, you implicitly use the this name, but you can also explicitly specify
Each non-static method in each class implies a this reference name, which points to the object that called the method
This usage:
Point to a member variable in a class
As an argument passed in the method
In the constructor method, this (...) Calling other constructor methods
Cannot appear in the static method, within the code block (super too)
8. Three main features of object-oriented
Encapsulation: not visible to external
Inheritance: The functionality of an extended class
Polymorphism: Overloading of methods, polymorphism of objects
Encapsulation of the class:
Private: Does not allow any other class to access it
Default (no modifier): Other classes under the same package can access it.
9.static Keywords (created when class loads, i.e. first use)
1.static variables: Class variables (static variables), cannot be declared in non-static methods, but can be used
2.static method: Class Method (static method), can only invoke other static members in this class, and can not appear this and super
3.STAITC Static code block: Executes and executes only once when the class is loaded, commonly used to initialize static member variables of a class
10. Packages (Package)
To facilitate the management of numerous classes and solve the problem of class naming conflicts , Java introduces the concept of package.
The role of the package: The package hides the class and resolves the problem of class naming conflicts.
Packaging: Package name, must be placed in the Java source file as the first statement (without this statement, the default is placed under the nameless package)
After compiling, the bytecode file for this class will be placed under the package name directory.
11. Compiling and generating the package
1. In the current directory, generate the byte code with the packet structure ('. ' = current directory)
Javac-d. Class name. java
2. Generate a byte code with packet structure in the specified directory
javac-d the specified directory (d:\test\) class name. java
3. Run:
You must run it on the specified directory at compile time above, Java package name. Class Name// no less write package name
Introduction to the main packages in 12.jdk6
java.lang-contains some of the core classes of the Java language, such as: String Math Integer System Thread
Java.util-contains some useful tool classes, such as defining system features, datetime, calendars, collection classes, Scanner
Java.io-Stream class with multiple input and output
Java.net-contains classes that perform network-related operations
Java.sql-java Some APIs for manipulating databases.
Java.text-contains classes and interfaces for working with text, dates, numbers, and messages
-------Android Training, Java training, look forward to communicating with you! ----------
Dark Horse Programmer-java Object-oriented "II"