当前位置:网站首页>Day 9 static abstract class interface
Day 9 static abstract class interface
2022-04-23 16:08: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();// No, static The modifier needs to be called first new An object
run();// Yes static Can be called directly
}
public void go() {
System.out.println("go");
}
public static void run() {
System.out.println("run");
}
}
abstract class


package oop.redo; // abstract class public abstract class Demo2 { public abstract void Sun(); }package oop.redo; //demo3 Inherit demo2 The abstract class of , But it needs to be rewritten demo2 Abstract methods in public class Demo3 extends Demo2{ @Override public void Sun() { System.out.println("say hi"); } }
Interface


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; // Class overrides methods in the interface 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://yzsam.com/2022/04/202204231602157351.html
边栏推荐
猜你喜欢

matplotlib教程05---操作图像

Unity Shader学习

Hyperbdr cloud disaster recovery v3 Version 2.1 release supports more cloud platforms and adds monitoring and alarm functions

Countdown 1 day ~ 2022 online conference of cloud disaster tolerance products is about to begin

How can poor areas without networks have money to build networks?
![[key points of final review of modern electronic assembly]](/img/17/007ca1f4fedd11ab878bddda3faf56.jpg)
[key points of final review of modern electronic assembly]

Matplotlib tutorial 05 --- operating images

Day (5) of picking up matlab

C, calculation method and source program of bell number

homwbrew安装、常用命令以及安装路径
随机推荐
Simple usage of dlopen / dlsym / dlclose
Win11/10家庭版禁用Edge的inprivate浏览功能
linux上启动oracle服务
保姆级Anaconda安装教程
Best practice of cloud migration in education industry: Haiyun Jiexun uses hypermotion cloud migration products to implement progressive migration for a university in Beijing, with a success rate of 1
撿起MATLAB的第(9)天
Vim使用Vundle安装代码补全插件(YouCompleteMe)
[split of recursive number] n points K, split of limited range
Nanny Anaconda installation tutorial
The principle and common methods of multithreading and the difference between thread and runnable
Leetcode-396 rotation function
Config learning notes component
Using JSON server to create server requests locally
安装Redis并部署Redis高可用集群
How to conduct application security test (AST)
Construction of esp32 compilation environment
New developments: new trends in cooperation between smartmesh and meshbox
Day (10) of picking up matlab
leetcode-374 猜数字大小
shell_ two