当前位置:网站首页>Use of constructors
Use of constructors
2022-06-11 06:00:00 【visionkiwi】
package oop.Demo01;
// There is only one specification for a project main Method
public class Application {
public static void main(String[] args) {
//new key word An object is instantiated
Person person = new Person(" skin ",12);
System.out.println(person.name+person.age);
}
}
package oop.Demo01;
public class Person {
// Even if a class doesn't write anything , It also has a way
// The definition constructor of the display
String name;
int age;
/* Default constructor */
// No arguments structure
// Instantiate the initial value
//1. Use new keyword , The essence is to call the constructor again
//2. Used to initialize values
public Person(){
this.name = " Pixiaopi ";// Define the initial value ( There can be no )
}
/* heavy load */
// There are parametric structures : Once a parametric construct is defined , A parameterless construct must display the definition
public Person(String test,int age){
this.name = test;
this.age = age;
}
}
/* Constructors : 1. Same as class name 2. no return value effect : 1.new, The essence is calling constructor 2. Initialize the value of the object Be careful : 1. After defining a parametric construct , If you want to use a nonparametric construct , The definition of the display is a parameterless construct idea Shortcut key :Alt + Insert ( Quick build construction ) this. = The current class */
边栏推荐
- 安装Oracle数据库
- All the benefits of ci/cd, but greener
- SQLI_ LIBS range construction and 1-10get injection practice
- NDK learning notes (12) native graphics API, using avilib to create an avi video player
- 使用Batch管理VHD
- Thymeleafengine template engine
- JS -- reference type
- What happened to the young man who loved to write code -- approaching the "Yao Guang young man" of Huawei cloud
- Sword finger offer 50: the first character that appears only once
- Wechat custom component - style - slot
猜你喜欢

NDK learning notes (VII) system configuration, users and groups

View controller and navigation mode

NDK learning notes (IX) POSIX sockect connection oriented communication

Sqli-libs range 23-24 filtration and secondary injection practice

Free get | full function version of version control software

Super details to teach you how to use Jenkins to realize automatic jar package deployment

Twitter data collection (content, fans, keywords, etc.)

All the benefits of ci/cd, but greener

Error:Execution failed for task ':app:buildNative'. & gt; A problem occurred'x/x/x/'NDK build' error resolution

Wechat custom component - style - slot
随机推荐
[IOS development interview] operating system learning notes
Sign for this "plug-in" before returning home for the new year
Sqli-libs post injection question 11-17 actual combat
Linux Installation redis
Free get | full function version of version control software
数组部分方法
Sword finger offer 50: the first character that appears only once
Functional interface lambda, elegant code development
handler
Jsonobject jsonarray for parsing
使用Batch读取注册表
What is a thread pool?
Managing VHDS using batch
Clear function of ArrayList
Yoyov5's tricks | [trick8] image sampling strategy -- Sampling by the weight of each category of the dataset
Servlet
[metadata]linkedin datahub
Informatica: six steps of data quality management
Configure the rust compilation environment
“All in ONE”一个平台解决所有需求,运维监控3.0时代已来