Home >Java >javaTutorial >Examples of classes and objects
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(); } }
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!