java-Classes and objects

Source: Internet
Author: User

Classes and objects

1. Objects

Cases:

Customer Category

Property:

Age: 26

Weight: 60kg

Name: Li Ming

Method:

Buy things

Pay money

Cashier class

Property:

Age: 30

Weight: 70kg

Name: Xiao Ming

Method:

Collect money

Credit card

2. Class:

is a mold that contains the properties and methods of the object, and the class is the type of the object.

3. Package:

Encapsulation is the wrapping of a thing (covering properties and methods).

Cases:

public class school{

Defining classes

//struct contains the variable

Char *name;

int age; ;

Ways to define people

public void People() {

System.out.println (name+ "name" +age+ "Age");

}
}


//define variables by struct

People a =new people

Assigning a value to an object

A. Name = "Xiaoming";
A. Age = ;


java-Classes and objects

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.