Java simple summary class and object-14 days study notes

Class and object

  • A class is a template is an abstract, an object is a concrete instance

method

  • Define, call

Object reference

  • In addition to the 8 types of reference types, we can all be called reference types
  • Objects are manipulated by reference: stack ------ "heap (address)

Object properties

  • Attributes are generally called fields, also called member variables
  • Default initialization

​ Number 0 or 0.0

​ char : u0000

​ boolean : false

​ Reference type: null

Definition of attributes

Modifier attribute type attribute name = attribute value

int a = 0;

Creation and use of objects

  1. The new keyword must be used to create the object, the constructor Person xiaoHuangRen = new Person();

  2. The attributes of the object xiaoHuangRen.name;

    ​ xiaoHuangRen.age;

    Object method xiaoHuangRen.sleep();

class

Static properties

Dynamic approach

Guess you like

Origin blog.csdn.net/yibai_/article/details/114803680