当前位置:网站首页>2021-04-27 classes and objects
2021-04-27 classes and objects
2022-06-23 10:07:00 【Deer like deer】
The relationship between classes and objects
Class is an abstract data type , He is the overall description of a certain kind of things / Definition , But it can't represent a specific thing
Objects are concrete instances of abstract concepts
package oop.demo2;
// Students
public class Student {
// attribute : Field
String name;
int age;
// Method
public void study(){
System.out.println(this.name+" I'm learning ");;
}
}
package oop.demo2;
// There should be only one project main Method
public class Application {
public static void main(String[]args){
// class : In the abstract , Instantiation
// Class will return its own object after instantiation
//student The object is a Student Class
Student xiaoming = new Student();
Student xiaohong = new Student();
xiaoming.name = " Xiao Ming ";
xiaohong.age = 18;
System.out.println(xiaoming.name);
System.out.println(xiaohong.age);
}
}
The essence of object-oriented programming is : Organize code as a class , The organization of objects ( encapsulation ) data
边栏推荐
- Personal blog system graduation project opening report
- 开发者,你对云计算可能有些误解
- 分布式锁的三种实现方式
- High performance computing center Infiniband overview
- Cloud native database Amazon RDS
- How to pass values to onclick events in thymeleaf
- Three methods to find the limit of univariate function -- lobida's rule and Taylor's formula
- 【CTF】 2018_ rop
- mysql乐观锁与悲观锁
- regular expression
猜你喜欢

Bioinformatics | 基于相互作用神经网络的有效药物-靶标关联预测

Nuxt.js spa与ssr的区别

Install the typescript environment and enable vscode to automatically monitor the compiled TS file as a JS file

Thin film interference data processing

Lu Qi invests in quantum computing for the first time

Liujinhai, architect of zhongang Mining: lithium battery opens up a Xintiandi for fluorine chemical industry

Lying trough, the most amazing paper artifact!

AI system frontier dynamics issue 38: Google has abandoned tensorflow?; Four GPU parallel strategies for training large models; Father of llvm: modular design determines AI future

Shengshihaotong enables high-quality development with industrial Digitalization

Copilot免费时代结束!正式版67元/月,学生党和热门开源项目维护者可白嫖
随机推荐
After installing these five plug-ins, pycharm can be used for takeoff!
Lying trough, the most amazing paper artifact!
高性能算力中心 — NVMe/NVMe-oF — NVMe-oF Overview
High performance computing center nvme / nvme of nvme of overview
Gorm 高级查询
我被提拔了,怎么和原来平级的同事相处?
马斯克 18 岁儿子请愿改名,欲断绝父子关系
构建信创产业生态,移动云立足全栈自主创新连放大招
Unable to enter the system normally, press F8 to select other items to try to enter
After the uncommitted transactions in the redo log buffer of MySQL InnoDB are persisted to the redo log, what happens if the transaction rollback occurs? How does the redo log handle this transaction
Install using snap in opencloudos NET 6
The usage of lambda of C
个人博客系统毕业设计开题报告
分布式常见面试题
Multithreaded exercises
[GXYCTF2019]BabySQli
Install the typescript environment and enable vscode to automatically monitor the compiled TS file as a JS file
RT-Thread 添加 msh 命令
Go language JSON processing
基于STM32设计的宠物投喂器