Classes and objects
Properties-Characteristics of an object
Each property of each object has a specific value
Method-The action that the object performs
Object: An entity used to describe an objective thing, consisting of a set of properties and methods
Objects have both property and method characteristics
Object properties and methods are often encapsulated together to reflect the characteristics of things, the two complement each other, can not be divided
A class is a mold that defines the characteristics (attributes) and behaviors (methods) that an object will have.
Class is the type of object
Unlike the int type has a method
All Java programs use class classes as the organizational unit
Keyword class defines a custom data type
Class simulates a real-world concept into a computer program
public class class Name {
Defining Attributes Section
Property 1 of type attribute 1;
Define Method Section
}
Steps to define a class
Define class names--write classes as properties--How to write classes
Steps for working with objects
Creating objects
Class Name Object name =new class name ();
School center=new School ();
Referencing object members: using "." Do the following
1. Referencing the properties of a class: Object name, property
2. Method of referencing a class: Object name, Method name ()
Center Name= "Beijing Centre";//Assign a value to the Name property
Center.showcenter ();//Call Showcenter () method
Java (iii)