当前位置:网站首页>第九天 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
边栏推荐
- 【第5节 if和for】
- [AI weekly] NVIDIA designs chips with AI; The imperfect transformer needs to overcome the theoretical defect of self attention
- 捡起MATLAB的第(9)天
- 腾讯Offer已拿,这99道算法高频面试题别漏了,80%都败在算法上
- Spark 算子之coalesce与repartition
- 捡起MATLAB的第(8)天
- MySQL - execution process of MySQL query statement
- Method 2 of drawing ROC curve in R language: proc package
- API IX JWT auth plug-in has an error. Risk announcement of information disclosure in response (cve-2022-29266)
- Configuration of multi spanning tree MSTP
猜你喜欢
Sortby use of spark operator
捡起MATLAB的第(6)天
Distinct use of spark operator
运维流程有多重要,听说一年能省下200万?
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
王启亨谈Web3.0与价值互联网“通证交换”
Spark 算子之sortBy使用
Master vscode remote GDB debugging
MySQL - execution process of MySQL query statement
Large factory technology implementation | industry solution series tutorials
随机推荐
捡起MATLAB的第(10)天
Compile, connect -- Notes
Algorithem_ ReverseLinkedList
Function summary of drawing object arrangement in R language
The length of the last word of the string
Day (6) of picking up matlab
【现代电子装联期末复习要点】
[open source tool sharing] MCU debugging assistant (oscillograph / modification / log) - linkscope
面试题 17.10. 主要元素
How do you think the fund is REITs? Is it safe to buy the fund through the bank
捡起MATLAB的第(7)天
捡起MATLAB的第(8)天
Spark 算子之filter使用
WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile
JVM - Chapter 2 - class loader subsystem
The principle and common methods of multithreading and the difference between thread and runnable
leetcode-374 猜数字大小
homwbrew安装、常用命令以及安装路径
Website pressure measurement tools Apache AB, webbench, Apache jemeter
MetaLife与ESTV建立战略合作伙伴关系并任命其首席执行官Eric Yoon为顾问