I. Understanding what classes and objects are
Everything is object.
1. Attributes--Characteristics of objects (characteristics)
2, Method--the action that the object can perform (what to do)
3, the definition of the object:
An objective, visible, or tangible entity composed of attributes and methods.
4, the class is abstracted by the object, can't see also touch
5. What are the relationships between classes and objects?
The class (which is general) is the abstraction of the object, and the object (concrete) is the materialization of the class.
Second, package-packaging (to wrap up a thing, and hide the internal details as far as possible)
1.2 Forms of expression: properties and Methods
2, the role of packaging:
Hide internal implementation details to make it easy to operate
3, the package embodied in Java:
Class--All Java code is written in the class (method)
MyEclipse tools in the form of projects, encapsulation
Iii. Creating and Using objects
1. Create a syntax for a class
Access modifier Class class name {
Properties
public void Method name () {
Cyclic structure, condition judgment (if, switch)
Output statement
}
}
2. Create objects
Class Name Object name =new class name ();
Scanner input=new Scanner (system.in);
How do I invoke properties and methods?
Member variable (property name), by: Object name. property name;
Method, through: Object name. Method Name ();
Four, object-oriented
Class--noun
Properties--Adjectives
Method--Verb
1. Communication between classes (Access): An object in a class that is new to another class, through the name of the object. The member name of the class
Members of the class: attributes (member variables), methods (member methods)
2. Advantages:
Information encapsulation and hiding,
Improve program security, reusability, maintainability
Step 1: Write the Class (properties, Methods)
property is not assigned a value in this class
method to output the value of the property
Step 2: Create a new class with main (test Class)
Step 3:
Create an object for the class of step 1
Object name. property = value; (from console assignment)
The name of the object. Method name ();//The value of the property is output
Java Object-oriented