Java (iii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.