当前位置:网站首页>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
边栏推荐
猜你喜欢

必须知道的RPC内核细节(值得收藏)!!!

ICLR 2022 | dynamic convolution tadaconv in video and efficient convolution video understanding model tadaconvnext

漫画 | Code Review快把我逼疯了!

RT-Thread 添加 msh 命令

Personal blog system graduation project opening report

陆奇首次出手投资量子计算

卧槽,最惊艳的论文神器!

安装typescript环境并开启VSCode自动监视编译ts文件为js文件

Dr. Sun Jian was commemorated at the CVPR conference. The best student thesis was awarded to Tongji Ali. Lifeifei won the huangxutao Memorial Award

Pet Feeder Based on stm32
随机推荐
Three implementation methods of distributed lock
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
2021-04-16递归
High performance computing center RDMA implementation technology
启明星辰华典大数据量子安全创新实验室揭牌,发布两款黑科技产品
Subscript operator of map
Go 单元测试
2021-05-07封装 继承 super this
春招面试经验汇总(技术岗)
J. Med. Chem. | RELATION: 一种基于靶标结构的深度学习全新药物设计模型
漫画 | Code Review快把我逼疯了!
同花顺推荐么?手机开户安全么?
[plugin:vite:import-analysis]Failed to resolve import “@/“ from ““.Does the file exist
Simple understanding of quick sort
在OpenCloudOS使用snap安装.NET 6
R和RStudio下载安装详细步骤
必须知道的RPC内核细节(值得收藏)!!!
数值计算方法
RPC kernel details you must know (worth collecting)!!!
构建信创产业生态,移动云立足全栈自主创新连放大招