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

腾讯域名怎么建设网站wordpress mu 安装

腾讯域名怎么建设网站,wordpress mu 安装,做网站什么都不懂 怎么做,云seo关键词排名优化软件目录 嵌套类#xff08;上#xff09; 4. 内部类 内部类对象创建语法 示例 5. 局部内部类 示例 6. 匿名内部类 示例 Java SE文章参考:Java SE入门及基础知识合集-CSDN博客 嵌套类#xff08;上#xff09; 4. 内部类 As with instance methods and variables, an…目录 嵌套类上 4. 内部类 内部类对象创建语法 示例 5. 局部内部类 示例 6. 匿名内部类 示例 Java SE文章参考:Java SE入门及基础知识合集-CSDN博客 嵌套类上 4. 内部类 As with instance methods and variables, an inner class is associated with an instance of its enclosing class and has direct access to that objects methods and fields. Also, because an inner class is associated with an instance, it cannot define any static members itself. 与实例方法和变量一样内部类与其所在类的实例相关联并且可以直接访问该对象的方法和字段。 另外由于内部类与实例相关联因此它本身不能定义任何静态成员。 内部类对象创建语法 外部类类名 . 内部类类名 对象名 new 外部类类名 (). new 内部类类名 (); 示例 使用内部类描述一辆汽车拥有一台发动机。 package com . wq . inner . clazz . inner ; public class Car { // 汽车         private double price ;         private String brand ;         private Engine engine ; // 汽车拥有的发动机         public Car ( double price , String brand ) {                 this . brand brand ;                 this . engine new Engine ( 国产 , 20000 );                 this . price price engine . price ;         }         public Car ( Engine engine , String brand , double price ){                 this . engine engine ;                 this . brand brand ;                 this . price price engine . price ;         }         public void show (){                 this . engine . show ();         }         class Engine { // 发动机                 private String type ; // 发动机类型                 private double price ; // 发动机价格                 public Engine ( String type , double price ) {                 this . type type ;                 this . price price ;                 }                 public void show (){                         System . out . println ( brand 汽车使用的是 type 发动机价格为 price );                 //如果内部类中存在于外部类同名的成员变量时想要使用外部类的同名成员变量需要加上 外部类类名.this.变量名                         System . out . println ( 汽车总价为 Car . this . price );                 }         } } package com . wq . inner . clazz . inner ; public class CarTest {         public static void main ( String [] args ) {                 Car c new Car ( 100000 , 奥拓 ); //c 是汽车类的成员因此 c 对象中有 Engine 类成员                 c . show ();                 Car . Engine engine new Car ( 100000 , 奥拓 ). new Engine ( 进口 , 50000 );                 Car c1 new Car ( engine , 奔驰 , 150000 );                 c1 . show ();                 Car . Engine engine1 c . new Engine ( 进口 , 50000 );                 Car c2 new Car ( engine1 , 奔驰 , 165600 );                 c2 . show ();         } } 5. 局部内部类 Local classes are classes that are defined in a block, which is a group of zero or more statements between balanced braces. You typically find local classes defined in the body of a method. 局部类是在一个块中定义的类该块是一组在平衡括号之间的零个或多个语句。 通常你会在方法的主体中找到定义的局部类。 示例 使用局部内部类描述使用计算器计算两个数的和。 package com . wq . inner . clazz . local ; public class LocalClass {         public static void main ( String [] args ) {                 int result calculate ( 1 , 3 );                 System . out . println ( result );         }         public static int calculate ( int a , int b ){         class Calculator {                 private int num1 , num2 ;                 public Calculator ( int num1 , int num2 ) {                         this . num1 num1 ;                         this . num2 num2 ;                 }                 public int calculate (){                         return num1 num2 ;                 }         }         Calculator c new Calculator ( a , b );                 return c . calculate ();         } } 6. 匿名内部类 Anonymous classes enable you to make your code more concise. They enable you to declare and instantiate a class at the same time. They are like local classes except that they do not have a name. Use them if you need to use a local class only once. 匿名类可以使你的代码更简洁。 它们使你在声明一个类的同时实例化它。 除了没有名称外它们类似于局部类。 如果只需要使用一次局部类则使用它们。 The syntax of an anonymous class expression is like the invocation of a constructor, except that there is a class definition contained in a block of code. 匿名类表达式的语法类似于构造方法的调用不同之处在于代码块中包含类定义。 示例 package com . wq . inner . clazz . anonymous ; public interface Calculate {         int calculate ( int a , int b ); } package com . wq . inner . clazz . anonymous ; public abstract class Animal {         public abstract void eat (); } package com . wq . inner . clazz . anonymous ; public class Student {         protected String name ;         protected int age ;         public Student ( String name , int age ) {                 this . name name ;                 this . age age ;         }         public void show (){                 System . out . println ( name \t age );         } } package com . wq . inner . clazz . anonymous ; public class AnonymousClass {         public static void main ( String [] args ) {                 int result calculate ( 10 , 20 );                 System . out . println ( result );                    Animal a new Animal () {                 Override                 public void eat () {                         System . out . println ( 老虎吃肉 );                 }         };                 a . eat ();                 Student stu new Student ( 好奇怪 , 20 ){                 Override                 public void show () {                         System . out . println ( age );                 }         };                 stu . show ();         }         public static int calculate ( int a , int b ){         //匿名内部类跟构造方法的调用很相似不同的地方在于匿名内部类里面还有类的主体                 Calculate c new Calculate () {                 Override                 public int calculate ( int a , int b ) {                         return a b ;                 }         };         return c . calculate ( a , b );         } } Java SE文章参考:Java SE入门及基础知识合集-CSDN博客
http://www.zqtcl.cn/news/300704/

相关文章:

  • 锦州网站建设渠道山西做网站的公司有哪些
  • 4线城市搞网站开发丹灶网站建设公司
  • 青岛网站建设seo优化wordpress分类标题自定义
  • 网站开发本地环境在海南注册公司需要多少钱
  • 济南网站开发去哪儿旅行app下载安装
  • 大城 网站北京做网站男生工资
  • 赣州网站建设百家号免费软件网
  • 在合肥做网站多少钱网站开发外包平台
  • 百度指数查询平台网站建设SEO优化哪家好
  • 网站怎么在成都备案中企动力如何
  • 免费数据统计网站app推广拉新一手渠道
  • 网站推广效果不好原因zac seo博客
  • 高端网站设计合肥网站建设个人网站建设公
  • 廊坊建站模板系统做效果图的网站
  • 建网站打开需要验证四川省成都市建设厅官网
  • 网站文章列表如何排版珠海建设工程信息网站
  • 郑州个人做网站建设银行招聘网站
  • 杭州网站设计公司联系亿企邦网站怎么上百度
  • 网站建设的未来网站不备案访问
  • 网站改版效果图怎么做网站建设的五个基本要素
  • 河南建站网站做o2o网站需要多少钱
  • 重庆企业网站定制开发公司wordpress用户页
  • 电子商务网站seo网站规划与设计方向
  • 外贸双语网站源码wordpress 柚子
  • 隆昌市住房和城乡建设厅网站html5网页成品代码
  • 泉州丰泽建设局网站wordpress设置logo和公司名
  • 网页与网站设计实验总结网上商城互联网网站开发
  • 学院宣传网站建设简介郑州加盟网站建设
  • 上海网站建设sheji021wordpress ssl 图片
  • 网站管理人员队伍建设说明材料搞笑网站建设目的和意义