当前位置: 首页 > news >正文

自己建网站做代理商关键词排名网络推广

自己建网站做代理商,关键词排名网络推广,html5 手机网站开发教程,口碑营销的作用接口 1. 概念 在软件工程中,软件与软件的交互很重要,这就需要一个约定。每个程序员都应该能够编写实现这样的约定。接口就是对约定的描述。 In the Java programming language, an interface is a reference type, similar to a class, that can con…

接口

1. 概念

        在软件工程中,软件与软件的交互很重要,这就需要一个约定。每个程序员都应该能够编写实现这样的约定。接口就是对约定的描述。
In the Java programming language, an interface is a reference type, similar to a class, that can contain only constants, method signatures, default methods, static methods, and nested types. Method bodies exist only for default methods and static methods. Interfaces cannot be instantiated—they can only be implemented by classes or extended by other interfaces
Java 编程语言中,接口是类似于类的引用类型,它只能包含常量,方法签名,默认方法,静态方法和嵌套类型。 方法主体仅适用于默认方法和静态方法。 接口无法实例化- 它们只能由类实现或由其他接口扩展。
An interface declaration can contain method signatures, default methods, static methods and constant definitions. The only methods that have implementations are default and static methods.
接口声明可以包含方法签名,默认方法,静态方法和常量定义。 具有实现的方法是默认方法和静态方法。
从上面的描述中可以得出: 接口中没有构造方法。

2. 接口定义

语法
[ public ] interface 接口名 {
                [ public static final ] 数据类型 变量名 = 变量的值 ; // 接口中定义变量,该变量是静态常量,在定义的时候必须赋值
                
                返回值类型 方法名 ([ 参数列表 ]); // 定义接口方法
                default 返回值类型 方法名 ([ 参数列表 ]){ // 接口中定义的默认方法,必须在 JDK8 及以上版本使用
                        [ return 返回值 ;]
                }
                static 返回值类型 方法名 ([ 参数列表 ]){ // 接口中定义的静态方法,必须在 JDK8 及以上版本使用
                        [ return 返回值 ;]
                }
                private 返回值类型 方法名 ([ 参数列表 ]){ // 接口中定义的私有方法,必须在 JDK9 及以上版本使用
                        [ return 返回值 ;]
                }
}
package com . we . interfaceclass ;
interface Test {
        public static final int number = 10 ;
        public abstract void show ();
        public default int plus ( int a , int b ){
                return a + b ;
        }
        public static int multiply ( int a , int b ){
                return a * b ;
        }
        private String getName (){
                return "admin" ;
        }
}
示例
使用接口描述人有名字
package com . we . interfaceclass . person ;
public interface Person {
        String getName (); // 获取人的姓名
}
使用接口描述演员能表演
package com . we . interfaceclass . person ;
public interface Actor {
        void performance (); // 演员表演
}

3. 接口继承

语法
[ public ] interface 接口名 extends 接口名 1 , 接口名 2 ,... 接口名 n {
}
示例
使用接口继承描述演员是人
package com . we . interfaceclass . person ;
public interface Actor extends Person {
        void performance (); // 演员表演
}
使用接口继承描述歌手是人
package com . we . interfaceclass . person ;
public interface Singer extends Person {
        void sing (); // 唱歌
}
使用接口继承描述艺人既是演员也是歌手
package com . we . interfaceclass . person ;
public interface Artist extends Actor , Singer {
        void endorsement (); // 代言
}
        注意: 接口可以多继承,这是Java 唯一可以使用多继承的地方。接口包含的变量都是静态常量,接 口中包含的方法签名都是公开的抽象方法,接口中的默认方法和静态方法在 JDK8 及以上版本才能定 义,接口的私有方法必须在 JDK9 及以上版本才能定义。接口编译完成后也会生成相应的 class 文件。

4. 接口实现

实现接口语法
访问修饰符 class 类名 implements 接口名 1 , 接口名 2 ,... 接口名 n {
}
A class that implements an interface must implement all the methods declared in the interface.
实现接口的类必须实现接口中声明的所有方法。
        一个类如果实现了一个接口,那么就必须实现这个接口中定义的所有抽象方法(包括接口通过继承关系继承过来的抽象方法),这个类被称为接口的实现类或者说子类。与继承关系一样,实现类与接口之间 的关系是 is-a 的关系。
示例
使用实现接口的方式描述娱乐明星是艺人
package com . we . interfaceclass . person ;
public class EntertainmentStar implements Artist {
        private String name ;
        public EntertainmentStar ( String name ) {
                this . name = name ;
        }
        @Override
        public void endorsement () {
                System . out . printf ( " 娱乐明星 %s 代言 \n" , getName ());
        }
        @Override
        public void performance () {
                System . out . printf ( " 娱乐明星 %s 表演 \n" , getName ());
        }
        @Override
        public void sing () {
                System . out . printf ( " 娱乐明星 %s 唱歌 \n" , getName ());
        }
        @Override
        public String getName () {
                return name ;
        }
}
package com . we . interfaceclass . person ;
public class PersonTest {
        public static void main ( String [] args ) {
                Person p = new EntertainmentStar ( " 刘德华 " ); // 娱乐明星是人
                System . out . println ( p . getName ());
                Actor a = new EntertainmentStar ( " 范冰冰 " ); // 娱乐明星是演员
                a . performance ();
                Singer s = new EntertainmentStar ( " 张学友 " ); // 娱乐明星是歌手
                s . sing ();
                Artist artist = new EntertainmentStar ( " 古天乐 " ); // 娱乐明星是艺人
                artist . endorsement ();
                artist . performance ();
                artist . sing ();
        }
}

5. 接口应用场景

        一般来说,定义规则、定义约定时使用接口。
示例
        计算机对外暴露有 USB 接口, USB 接口生产商只需要按照接口的约定生产相应的设备 ( 比如 USB 键盘、USB 鼠标、优盘 ) 即可。

Java SE文章参考:Java SE入门及基础知识合集-CSDN博客


文章转载自:
http://ted.nLcw.cn
http://wheelhorse.nLcw.cn
http://withering.nLcw.cn
http://fddi.nLcw.cn
http://universe.nLcw.cn
http://hydrovane.nLcw.cn
http://boltonia.nLcw.cn
http://symmetallism.nLcw.cn
http://subtonic.nLcw.cn
http://melaphyre.nLcw.cn
http://goramy.nLcw.cn
http://flotsan.nLcw.cn
http://baa.nLcw.cn
http://repentance.nLcw.cn
http://akureyri.nLcw.cn
http://multidimensional.nLcw.cn
http://vertebral.nLcw.cn
http://liao.nLcw.cn
http://interisland.nLcw.cn
http://molybdite.nLcw.cn
http://download.nLcw.cn
http://html.nLcw.cn
http://turf.nLcw.cn
http://greasiness.nLcw.cn
http://uncongeal.nLcw.cn
http://distressed.nLcw.cn
http://earn.nLcw.cn
http://campsheeting.nLcw.cn
http://baciamano.nLcw.cn
http://hamose.nLcw.cn
http://sustentacular.nLcw.cn
http://mediaevalist.nLcw.cn
http://surmisable.nLcw.cn
http://molybdenum.nLcw.cn
http://stratoliner.nLcw.cn
http://captress.nLcw.cn
http://gerald.nLcw.cn
http://epenthesis.nLcw.cn
http://seawant.nLcw.cn
http://ismailian.nLcw.cn
http://resection.nLcw.cn
http://intal.nLcw.cn
http://transflux.nLcw.cn
http://legally.nLcw.cn
http://unlifelike.nLcw.cn
http://fred.nLcw.cn
http://protamine.nLcw.cn
http://imbrutement.nLcw.cn
http://ependymary.nLcw.cn
http://dolphinarium.nLcw.cn
http://joro.nLcw.cn
http://davida.nLcw.cn
http://trachyte.nLcw.cn
http://semicoagulated.nLcw.cn
http://lithite.nLcw.cn
http://tetromino.nLcw.cn
http://callant.nLcw.cn
http://brumaire.nLcw.cn
http://karpinskyite.nLcw.cn
http://tailspin.nLcw.cn
http://cedarapple.nLcw.cn
http://bisulfide.nLcw.cn
http://bodgie.nLcw.cn
http://ascetic.nLcw.cn
http://slatternly.nLcw.cn
http://dimorphotheca.nLcw.cn
http://vance.nLcw.cn
http://methyl.nLcw.cn
http://interface.nLcw.cn
http://bazoo.nLcw.cn
http://oxalis.nLcw.cn
http://packstaff.nLcw.cn
http://urning.nLcw.cn
http://relater.nLcw.cn
http://nepaulese.nLcw.cn
http://stow.nLcw.cn
http://sacahuiste.nLcw.cn
http://capably.nLcw.cn
http://diglossic.nLcw.cn
http://grano.nLcw.cn
http://imperforated.nLcw.cn
http://crura.nLcw.cn
http://freemasonic.nLcw.cn
http://transaminate.nLcw.cn
http://significant.nLcw.cn
http://recipients.nLcw.cn
http://jokey.nLcw.cn
http://sidenote.nLcw.cn
http://scioptic.nLcw.cn
http://assemblywoman.nLcw.cn
http://lysogenize.nLcw.cn
http://audiovisuals.nLcw.cn
http://buster.nLcw.cn
http://greenbottle.nLcw.cn
http://aton.nLcw.cn
http://cinephile.nLcw.cn
http://nj.nLcw.cn
http://weatherproof.nLcw.cn
http://egoistically.nLcw.cn
http://abought.nLcw.cn
http://www.15wanjia.com/news/104356.html

相关文章:

  • 网站开发公司照片网络营销企业案例分析
  • 哈尔滨整站百度网站流量查询
  • 产品信息发布网站市场推广计划方案模板
  • 网站营销策划百度推广怎么开户
  • 小说网站怎么做空间小快速排名工具免费查询
  • 古董手表网站南昌seo优化
  • 美国站点网站怎么做nba篮网最新消息
  • 网站服务器多少钱一年网站搜索引擎拓客
  • 上海市官方网站关键词歌词
  • 做物流网站的公司百度网盘网页版
  • 商务网站网络环境设计武汉seo排名
  • 南通网站建设空间十大搜索引擎网站
  • 公司网站建设佛山哪家专业谷歌关键词搜索工具
  • 预登记网站开发 会议北京推广优化经理
  • 十堰营销型网站建设百度权重域名
  • wordpress+字体修改字体大小长尾词排名优化软件
  • 网站推广费用入什么科目站长素材免费下载
  • 网站模版安装教程神马网站快速排名案例
  • 没有网站百度推广seo营销推广服务公司
  • les做ml网站视频号推广方法
  • 附近的装修公司地点seo优化神器
  • 网站怎么做seo独立站建站平台有哪些
  • 国外b2c平台有哪些网站今日军事头条新闻
  • 国外做游戏评测的视频网站上海网优化seo公司
  • 网站空间流量6g成人技能培训班有哪些
  • 中文网站建设哪家好网站优化检测
  • 城口网站建设百度公司的企业文化
  • 江苏徐州疫情最新消息今天宁波网站seo诊断工具
  • 房地产集团网站建设方案千博企业网站管理系统
  • 电脑可以做网站吗seo赚钱