当前位置:网站首页>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
边栏推荐
- Year end answer sheet! Tencent cloud intelligent comprehensive strength ranks first in China!
- 2021-04-27类和对象
- Typora set up image upload service
- Servlet-02 lifecycle
- sql根据比较日期新建字段
- [plugin:vite:import-analysis]Failed to resolve import “@/“ from ““.Does the file exist
- thymeleaf如何取url中请求参数值?
- How does thymeleaf get the value of the request parameter in the URL?
- 【CTF】 2018_ rop
- Build a security video monitoring platform using Huawei cloud ECS server
猜你喜欢

2022 gdevops global agile operation and maintenance summit - essence playback of Guangzhou station (with PPT download)

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

Build a security video monitoring platform using Huawei cloud ECS server

Copilot免费时代结束!正式版67元/月,学生党和热门开源项目维护者可白嫖

数值计算方法

2021-04-15

Web -- Information Disclosure

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

马斯克 18 岁儿子请愿改名,欲断绝父子关系

ICLR 2022 | dynamic convolution tadaconv in video and efficient convolution video understanding model tadaconvnext
随机推荐
个人博客系统毕业设计开题报告
高性能算力中心 — NVMe/NVMe-oF — NVMe-oF Overview
Pet Feeder Based on stm32
ICLR 2022 | 视频中的动态卷积TAdaConv以及高效的卷积视频理解模型TAdaConvNeXt
XML related interview questions
The era of copilot free is over! The official version is 67 yuan / month, and the student party and the defenders of popular open source projects can prostitute for nothing
我被提拔了,怎么和原来平级的同事相处?
给RepVGG填坑?其实是RepVGG2的RepOptimizer开源
Confessing with Snake games (with source code)
Jump game of leetcode topic analysis
分布式锁的三种实现方式
Distributed common interview questions
Lu Qi invests in quantum computing for the first time
必须知道的RPC内核细节(值得收藏)!!!
快速排序的简单理解
Three methods to find the limit of univariate function -- lobida's rule and Taylor's formula
谷贱伤农,薪贱伤码农!
数值计算方法
Qiming Xingchen Huadian big data quantum security innovation laboratory was unveiled and two black technology products were released
J. Med. Chem. | RELATION: 一种基于靶标结构的深度学习全新药物设计模型