当前位置:网站首页>第九天 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
边栏推荐
- R语言中绘制ROC曲线方法二:pROC包
- volatile的含义以及用法
- C language self compiled string processing function - string segmentation, string filling, etc
- Website pressure measurement tools Apache AB, webbench, Apache jemeter
- linux上啟動oracle服務
- gps北斗高精度卫星时间同步系统应用案例
- 王启亨谈Web3.0与价值互联网“通证交换”
- Configuration of multi spanning tree MSTP
- Go language, condition, loop, function
- New developments: new trends in cooperation between smartmesh and meshbox
猜你喜欢

MetaLife与ESTV建立战略合作伙伴关系并任命其首席执行官Eric Yoon为顾问

Tencent offer has been taken. Don't miss the 99 algorithm high-frequency interview questions. 80% of them are lost in the algorithm

面试题 17.10. 主要元素

API IX JWT auth plug-in has an error. Risk announcement of information disclosure in response (cve-2022-29266)

Spark 算子之sortBy使用

Using JSON server to create server requests locally

糖尿病眼底病变综述概要记录

5分钟,把你的Excel变成在线数据库,神奇的魔方网表excel数据库

Config组件学习笔记

Redis master-slave replication process
随机推荐
shell_2
Partitionby of spark operator
下载并安装MongoDB
WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile
The biggest winner is China Telecom. Why do people dislike China Mobile and China Unicom?
Grbl learning (I)
Master vscode remote GDB debugging
5 minutes, turn your excel into an online database, the magic cube net table Excel database
Vision of building interstellar computing network
Merging of Shanzhai version [i]
[section 5 if and for]
Homewbrew installation, common commands and installation path
Named in pytoch_ parameters、named_ children、named_ Modules function
捡起MATLAB的第(6)天
TIA botu - basic operation
Large factory technology implementation | industry solution series tutorials
Interview questions of a blue team of Beijing Information Protection Network
Day (6) of picking up matlab
Method 2 of drawing ROC curve in R language: proc package
Unity Shader学习