Class and Object focus

Source: Internet
Author: User

first, the concept :

All things are objects

Class-To-object relationships: Classes are types of objects, objects are instances of classes

Two, the object has two characteristics:

Properties: Characteristics of an object (e.g. name, gender)

Method: An action performed by an object (such as: eating, and ...). )

Third, object, package

Object: An entity used to describe an objective thing, consisting of a set of practices and methods.

Encapsulation: Encapsulating properties and methods into an object

Pros: Hide its internal details without revealing external details

IV. specification of class names in Java

1. Capitalize the first letter of the class

2. The class name cannot use the Java keyword

3. Cannot contain other characters except the "_" and "$" symbols

4. Cannot contain numbers and Chinese characters

※ class is the object of class, all classes are subclasses of object

※java is an object-oriented language

V. Definition of Class

Access modifier Class class name {

Access modifier data Type property name;

The access modifier method returns a value type method name () {

}

}

Vi. invocation of properties and methods in a class

Use the object name "." Make a call (make sure the object has been created)

For example:

Student stu=new Student ();

Stu.name= "Zhang San";

Class and Object focus

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.