Home > Java > javaTutorial > body text

Examples of classes and objects

零下一度
Release: 2017-06-26 14:48:44
Original
2038 people have browsed it

 1. A class is an abstraction of an object, and an object is a concrete instance of a class. Classes are abstract and do not occupy memory, while objects are concrete and occupy storage space.

 2. A class is a blueprint for creating objects. It is a software template that defines the methods and variables included in objects of a specific type.

 3. Classes and objects are like the relationship between drawings and objects, and the relationship between molds and castings.

For example: Human beings are a concept. Human beings have attributes such as height and weight. Humans can cook, talk, etc.

Xiao Ming is a specific person, that is, an example. His attributes are a specific height of 200cm and a weight of 180kg. His method of cooking is specific. He eats a bowl of white rice and says "1234" talk.

class Test{
    public static void main (String[] args){
         Student student = new Student();
    }
}
Copy after login

 

The above is the detailed content of Examples of classes and objects. 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!