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

佛山信息技术网站开发做商城网站怎么做

佛山信息技术网站开发,做商城网站怎么做,mvc 5 做网站的教程,做网站必须要切图吗接口 1. 概念 在软件工程中#xff0c;软件与软件的交互很重要#xff0c;这就需要一个约定。每个程序员都应该能够编写实现这样的约定。接口就是对约定的描述。 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://www.hkea.cn/news/14370317/

相关文章:

  • 一起做网站怎么下单常州市城投建设工程招标有限公司网站
  • 如何构建企业网站网站加速cdn
  • php 手机网站开发临沂网站建设选盛誉
  • 网站建设中的矢量图标wordpress setup-config.php空白
  • 南阳网站改版深圳勘察设计协会网站
  • 网站建设佰首选金手指十捕鱼网站建设
  • 网站查询域名ip解析福州百度关键词排名
  • 1 建设网站目的是什么如何编写网站开发文档
  • 网页制作素材网站推荐西宁做网站制作的公司
  • 用dw做的网站怎么发布到网上职业培训机构排名前十
  • 教学网站开发源码搬瓦工 wordpress
  • 空壳网站主体注销中山比好的做网站的公司
  • 青岛网站建设软件做网站怎么
  • p站关键词排名网站建设 报价单
  • 网站后台多附件上传网站建设书籍免费
  • ps制作个人网站广州市手机网站建设公司
  • 湛江建设局网站wordpress改地址后打不开
  • 医院网站域名备案哈尔滨免费网站制作
  • 有趣的网站知乎建设部网站一级建造师
  • 昌邑做网站的公司河南省网站制作公司
  • 上海专业网站建设网深圳松岗 网站建设
  • 网站建设信息介绍扫码员在哪个网站可以做
  • 怎么建设小说网站seogw
  • 建设网站说只给前端源码是什么意思wordpress 首页加载延迟
  • 个人网站如何做即时支付WordPress设置API
  • 株洲网站建设服务公司手机网站如何排版
  • 餐饮手机微网站怎么做深圳布吉做网站
  • html网站开发工具下载高端品牌女装连衣裙
  • 怎样建设淘宝网站如何制作小程序赚钱
  • 创建网站的费用台州免费建站