当前位置:网站首页>第九天 static 抽象类 接口
第九天 static 抽象类 接口
2022-04-23 16:02:00 【Students Mr sun】
static
package oop.redo; public class Demo1 { private static int a; private double b; public static void main(String[] args) { Demo1.a=1; System.out.println(Demo1.a); Demo1 a= new Demo1(); a.b=0.4; System.out.println(a.b); a.go();//没有static修饰符的调用需要先new一个对象 run();//有static的可以直接调用 } public void go() { System.out.println("go"); } public static void run() { System.out.println("run"); } }
抽象类
package oop.redo; //抽象类 public abstract class Demo2 { public abstract void Sun(); }package oop.redo; //demo3继承demo2的抽象类,但是需要重写demo2中的抽象方法 public class Demo3 extends Demo2{ @Override public void Sun() { System.out.println("say hi"); } }
接口
package oop.redo; public interface Userservice { void add(String name); void delete(String name); void update(String name); void select(String name); }package oop.redo; //类重写接口中方法 public class Userserviceimp implements Userservice{ @Override public void add(String name) { System.out.println(name); } @Override public void delete(String name) { System.out.println(name); } @Override public void update(String name) { System.out.println(name); } @Override public void select(String name) { System.out.println(name); } }
版权声明
本文为[Students Mr sun]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_37138380/article/details/120018416
边栏推荐
- Go language, condition, loop, function
- C language self compiled string processing function - string segmentation, string filling, etc
- 一文读懂串口及各种电平信号含义
- 299. 猜数字游戏
- 捡起MATLAB的第(8)天
- Install redis and deploy redis high availability cluster
- GRBL学习(一)
- 保姆级Anaconda安装教程
- Meaning and usage of volatile
- utils. Deprecated in35 may be cancelled due to upgrade. What should I do
猜你喜欢
Metalife established a strategic partnership with ESTV and appointed its CEO Eric Yoon as a consultant
volatile的含义以及用法
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
CVPR 2022 quality paper sharing
下载并安装MongoDB
腾讯Offer已拿,这99道算法高频面试题别漏了,80%都败在算法上
Homewbrew installation, common commands and installation path
Tencent offer has been taken. Don't miss the 99 algorithm high-frequency interview questions. 80% of them are lost in the algorithm
WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile
C, calculation method and source program of bell number
随机推荐
Day (2) of picking up matlab
Day (9) of picking up matlab
GRBL学习(二)
Spark 算子之groupBy使用
utils. Deprecated in35 may be cancelled due to upgrade. What should I do
C语言自编字符串处理函数——字符串分割、字符串填充等
[key points of final review of modern electronic assembly]
[split of recursive number] n points K, split of limited range
API IX JWT auth plug-in has an error. Risk announcement of information disclosure in response (cve-2022-29266)
Vision of building interstellar computing network
OAK-D树莓派点云项目【附详细代码】
Redis master-slave replication process
The biggest winner is China Telecom. Why do people dislike China Mobile and China Unicom?
ESP32编译环境的搭建
The principle and common methods of multithreading and the difference between thread and runnable
捡起MATLAB的第(5)天
ESP32_ Arduino
Unity Shader学习
Named in pytoch_ parameters、named_ children、named_ Modules function
Homewbrew installation, common commands and installation path