当前位置:网站首页>Static keyword and inheritance, polymorphic and special classes
Static keyword and inheritance, polymorphic and special classes
2022-06-12 04:59:00 【なんでもないゃ】
static keyword : use static Modifiers represent methods and variables that belong to a class ; Non static member variables cannot be used in static methods , Static variables can be used in non static methods , You can also use non static variables , This is because , Static variables and methods are loaded as classes are loaded , The common constructor and variables are loaded when the object is created , Generally, the class is loaded first and then the object is loaded ; Static member variables are common , Loaded in the method area , Normal member variables are in the heap ;
Loading order : Static code block > Code block > Construction method ; Parent static code block > Subclass static code block > Parent code block > Parent class constructor > Subclass code block > Subclass construction method ;
Constructor and member methods : The constructor has the same name as the class , The constructor does not return a value , Member methods do not have the same name as the class , To write the return value ;
Singleton design pattern : A class provides only one object ; technological process :1、 Privatized construction method , use private modification ;2、 Declare the object of this class in this class , use private static modification ;3、 Write the get Method returns the object , use public modification ;
Slacker type : The second step is to create the object when declaring the object ;
Hungry Chinese style : The second step is to declare only objects , The third step is get Method , That is, create the object when calling ( recommend );
final A decorated class indicates that it cannot be inherited ,final A modifier means that the method cannot be overridden ,final Decorating a member variable means that the variable must be initialized and its value cannot be changed before use , Usually use public static final Modifier variables represent constants , Use capital letters to indicate , Underline between letters _ Connect ;
polymorphic : Many forms of the same thing ; Parent type Object name = new Subclass type (); This object can call methods unique to the parent class , You cannot call methods unique to subclasses ; When a subclass overrides a method in the parent class , Methods in the parent class are called during compilation , The runtime calls methods in subclasses , If the method is static , Methods in the parent class are called both during compilation and operation ;
Polymorphism means : Shielding the differences of different subclasses and realizing general programming will bring different effects ;
边栏推荐
- Drive safety coding & troubleshooting guide
- Pupanvr hardware and software board side development environment configuration (4)
- Uview customer management JS
- Simple Tetris
- 【cjson】根节点注意事项
- File contains (regardless of suffix) Apache log remote file contains PHP encapsulated pseudo protocol:
- Ecosystem type distribution data, land use data, vegetation type distribution and nature reserve distribution data
- 2022 fusion welding and thermal cutting recurrent training question bank and simulation examination
- Ten trends of Internet Security in 2022 industry released
- L1-066 cat is liquid (5 points)
猜你喜欢

JWT learning and use

Map coordinate conversion of Baidu map API

One dragon and one knight accompanying programmers are 36 years old

ShanMeng and Beijing Adoption Day start NFT digital collection public offering

22-2-28 there are many things to do at work today, ETH analysis

CCF access control system

InnoDB data storage structure – MySQL

Ecosystem type distribution data, land use data, vegetation type distribution and nature reserve distribution data

Introduction to MMS memory optimization of Hisilicon MPP service

Data processing and data set preparation
随机推荐
Normalized vegetation index (NDVI) data, NPP data, GPP data, evapotranspiration data, vegetation type data, ecosystem type distribution data
1009 word search
【cjson】根节点注意事项
Ten trends of Internet Security in 2022 industry released
Main business objects of pupanvr record (5)
The master programmer "plays" a C program that is not like C
[GIS tutorial] ArcGIS for sunshine analysis (with exercise data download)
【C语言】实现字符串截取功能
Sword finger offer30 days re brush
Pupanvr- establishment of development environment and diary, addition of some basic tool functions (3)
Layer sublayer assigns values to the page elements of the parent layer to achieve the effect of transferring values to the page of the parent layer
One dragon and one knight accompanying programmers are 36 years old
Differences between in and not in, exists and not exists in SQL and performance analysis
Interview must ask: summary of ten classic sorting algorithms
Uview customer management JS
Pupanvr- some tool class objects (6)
Musk promotes the development of fascinating new products partners remind important questions
4.3 模拟浏览器操作和页面等待(显示等待和隐式等待、句柄)
Ray. Tune visual adjustment super parameter tensorflow 2.0
Day17 array features array boundary array application traversal array multidimensional array creation and traversal arrays operation array bubble sort