当前位置:网站首页>第九天 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
边栏推荐
- GRBL学习(二)
- linux上启动oracle服务
- Load Balancer
- js正则判断域名或者IP的端口路径是否正确
- Function summary of drawing object arrangement in R language
- The length of the last word of the string
- Pgpool II 4.3 Chinese Manual - introductory tutorial
- Go language, condition, loop, function
- Day (8) of picking up matlab
- Matplotlib tutorial 05 --- operating images
猜你喜欢
Nanny Anaconda installation tutorial
homwbrew安装、常用命令以及安装路径
C, calculation method and source program of bell number
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
Matplotlib tutorial 05 --- operating images
Import address table analysis (calculated according to the library file name: number of imported functions, function serial number and function name)
5 minutes, turn your excel into an online database, the magic cube net table Excel database
Jour (9) de ramassage de MATLAB
Pgpool II 4.3 Chinese Manual - introductory tutorial
Day (6) of picking up matlab
随机推荐
linux上启动oracle服务
[self entertainment] construction notes week 2
ES常用查询、排序、聚合语句
WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile
新动态:SmartMesh和MeshBox的合作新动向
Win11 / 10 home edition disables the edge's private browsing function
Leetcode-374 guess the size of the number
pywintypes. com_ Error: (- 2147221020, 'invalid syntax', none, none)
C#,贝尔数(Bell Number)的计算方法与源程序
Matplotlib tutorial 05 --- operating images
C, calculation method and source program of bell number
Configuration of multi spanning tree MSTP
ESP32编译环境的搭建
leetcode-396 旋转函数
PS add texture to picture
Open source project recommendation: 3D point cloud processing software paraview, based on QT and VTK
Distinct use of spark operator
Compile, connect -- Notes
Day (4) of picking up matlab
捡起MATLAB的第(6)天