Home > Java > javaTutorial > body text

What are the uses of java classes?

青灯夜游
Release: 2019-11-18 15:02:14
Original
5388 people have browsed it

What are the uses of java classes?

#What are the uses of java classes?

A class is a collection of objects with common properties and behaviors. A class defines the properties and methods of an object. It can be said that a class is a template that defines properties and methods common to multiple objects.

Multiple objects of this class can be instantiated through classes. Each object has different attribute values. It can be said that classes are like design drawings, and objects are like multiple buildings built according to the drawings.

What is a class?

A class is a collection of entities with certain common characteristics. It is an abstract data type, which is an abstraction of entities with the same characteristics. In object-oriented programming languages, a class is an abstraction of the properties and behavior of a type of "thing".

Give an example to illustrate the following category. For example, Person (person) is a category, then a specific person "Zhang San" is the object of the "human" category, and "name, height, weight" and other information They are the attributes of the object, and human actions such as "eating, getting dressed," etc. are the methods of the object.

In short, a class is a collection of things with the same characteristics, and an object is a specific instance of a class. At the same time, classes have polymorphism and inheritance. For example, "human beings" can be divided into "men, women", "elderly people, children", then "men, women" are subclasses of "human beings" and so on.

The importance of classes:All Java programs use class as the organizational unit

Composition of classes: properties and methods

Steps to define a class

a. Define the class name

b. Write the attributes of the class

c. Write the method of the class

What are the uses of java classes?

What are the uses of java classes?

The above is the detailed content of What are the uses of java classes?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!