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

wordpress做论坛网站网站服务器一年的费用

wordpress做论坛网站,网站服务器一年的费用,合肥建设云,wordpress上传大视频1.什么是内部类 在一个类的里面再定义一个类,新定义的这个类就是内部类 举例:在Outer类的里面定义一个Inter类 class Outer{class Inter{} } 在这里Outer叫外部类,Inter叫内部类 内部类的应用场景 定义一个汽车类: 属性&#xf…

1.什么是内部类

在一个类的里面再定义一个类,新定义的这个类就是内部类

举例:在Outer类的里面定义一个Inter类

class Outer{class Inter{}
}

在这里Outer叫外部类,Inter叫内部类


内部类的应用场景

定义一个汽车类:

属性:汽车品牌,型号,价格,发动机的型号和使用年限的等等

这里发动机是一个独立的个体,但是又依附于汽车,单独纯在没有意义

代码示例:

class Car{           //汽车类String carName;int carAge;int carPrice;class Engine{     //发动机String engineName;int engineAge;}
}

注意:

内部类表示的事物是外部类的一部分

内部类单独出现没有任何意义


内部类的访问特点

1.内部类可以直接访问外部类的成员,包括私有

2.外部类要访问内部类的成员,必须创建对象

2.成员内部类

1.成员内部类是写在成员位置的,属于外部类的成员(上述Enging类就是成员内部类)

2.成员内部类可以被一些修饰符所修饰,比如:private,default(默认),protected,public,static(被static修饰的成员内部类叫静态内部类)

3.在成员内部类里面,JDK16之前不能定义静态变量,JDK16以后才可定义静态变量

如何获取成员内部类

1.直接创建

格式:

外部类.内部类.对象名=外部类对象.内部类对象()
Outer.Inner oi=new Outer().new Inner();

2.外部类编写方法,对外提供内部类对象

样例:

class Car{String carName;int carAge;int carPrice;
//private修饰的内部类,main无法访问,也不能使用外部类.出来private class Engine{String engineName;int engineAge;}
//获取内部类的方法public Engine getinstance(){return new Engine();}}
public class T1 {public static void main(String[] args) {
//方法1:创建一个外部类对象,用Object形成多态接收内部类
Car car=new Car();
Object en=car.getinstance();
//方法二,直接使用内部类
Car car1=new Car();System.out.println(car1.getinstance());}
}

成员内部类面试题:

class Outer{int a=10;class Inter{int a=20;public void show(){int a=30;System.out.println();//打印10System.out.println();//打印20System.out.println();//打印30}}
}

当变量名不同使,直接调用即可

当外部类和内部类还有局部的变量名相同时,直接打印会遵循就近原则

想要打印分别打赢就可以按下面这种方式调用

class Outer{int a=10;class Inter{int a=20;public void show(){int a=30;System.out.println(Outer.this.a);//打印10System.out.println(this.a);//打印20System.out.println(a);//打印30}}
}

 

3.静态内部类

1.静态内部类就是被static修饰的成员内部类

2.静态内部类只能访问外部类中的静态变量和静态方法,如果要访问非静态的变量和方法,需要创建对象

3.创建静态内部类对象的格式:

外部类名.内部类名 对象名=new 外部类名.内部类名();
Outer.Inter oi=new Outer.Inter();

4.调用静态内部类中非静态的方法:先创建对象,使用对象调用

5.调用静态内部类中的静态方法:外部类名.内部类名.方法名();

4.局部内部类

1.将内部类定义在方法里面的类就叫做局部内部类,类似与方法中的局部变量

2.外界无法直接使用,需要在方法内部创建对象并使用

3.该类可以直接访问外部类的成员,也可访问方法类的局部变量

5.匿名内部类(重点

匿名内部类本质上就是隐藏了名字的内部类

格式:

new 类名或接口名(){
重写方法;
}举例:
new Inter(){
public void show(){}
}

遵循编译看左边,运行看右边的原则

Swin s=new Swin(){//实现了多态
public void swin(){
sout("重写接口里面swin的方法");
}
};
s.swin();

匿名内部类是一个对象,可以直接点方法调用自己类里面的方法

new Swin(){
public void swin(){
sout("重写接口里面swin的方法");
}
}.swin();

使用场景:

1.当方法的参数是接口或者类时

2.以接口为例,可以传递这个接口的实现类对象

3.如果实现类只要使用一次,就可以使用匿名内部类简化代码

注意:匿名内部类可以写在局部位置也可以写在成员位置


文章转载自:
http://dinncowolves.ydfr.cn
http://dinncooutmaneuvre.ydfr.cn
http://dinncotrityl.ydfr.cn
http://dinncofatstock.ydfr.cn
http://dinncopenniform.ydfr.cn
http://dinncoscurf.ydfr.cn
http://dinncohemostat.ydfr.cn
http://dinncopassivate.ydfr.cn
http://dinncoloire.ydfr.cn
http://dinncoaperture.ydfr.cn
http://dinncosclerotioid.ydfr.cn
http://dinncosinewy.ydfr.cn
http://dinncohydrosulfurous.ydfr.cn
http://dinncocyder.ydfr.cn
http://dinncohealer.ydfr.cn
http://dinncobrasier.ydfr.cn
http://dinncopapilio.ydfr.cn
http://dinncoinsufficience.ydfr.cn
http://dinncomanyat.ydfr.cn
http://dinncoserialism.ydfr.cn
http://dinncocosmic.ydfr.cn
http://dinncostrother.ydfr.cn
http://dinncomillilambert.ydfr.cn
http://dinncohomonuclear.ydfr.cn
http://dinncofalsehood.ydfr.cn
http://dinncodramshop.ydfr.cn
http://dinncogruyere.ydfr.cn
http://dinncohogarthian.ydfr.cn
http://dinncoredeveloper.ydfr.cn
http://dinncogrill.ydfr.cn
http://dinncolandline.ydfr.cn
http://dinncocoffeemaker.ydfr.cn
http://dinncodecruit.ydfr.cn
http://dinncosyndactylous.ydfr.cn
http://dinncoantiquarian.ydfr.cn
http://dinnconorwards.ydfr.cn
http://dinncothermidor.ydfr.cn
http://dinncoepizoon.ydfr.cn
http://dinncospinny.ydfr.cn
http://dinncoangelically.ydfr.cn
http://dinncoraggie.ydfr.cn
http://dinncolaundromat.ydfr.cn
http://dinncoasprawl.ydfr.cn
http://dinncoburstproof.ydfr.cn
http://dinncohorsy.ydfr.cn
http://dinncohypochondria.ydfr.cn
http://dinncowondering.ydfr.cn
http://dinncoantifederal.ydfr.cn
http://dinncoreclama.ydfr.cn
http://dinncoveni.ydfr.cn
http://dinncowalking.ydfr.cn
http://dinncomilimetre.ydfr.cn
http://dinncotouchline.ydfr.cn
http://dinncodebrett.ydfr.cn
http://dinncometrication.ydfr.cn
http://dinncojacamar.ydfr.cn
http://dinncoyoke.ydfr.cn
http://dinncoarminian.ydfr.cn
http://dinncozoosterol.ydfr.cn
http://dinncodynastic.ydfr.cn
http://dinncoclaudicant.ydfr.cn
http://dinncochromous.ydfr.cn
http://dinncoaseasonal.ydfr.cn
http://dinncococklestairs.ydfr.cn
http://dinncoinviolability.ydfr.cn
http://dinncocharterage.ydfr.cn
http://dinncopious.ydfr.cn
http://dinncooctaploid.ydfr.cn
http://dinncoargentate.ydfr.cn
http://dinncoworkfellow.ydfr.cn
http://dinncosbw.ydfr.cn
http://dinncodevisee.ydfr.cn
http://dinncopolymerization.ydfr.cn
http://dinncoligeance.ydfr.cn
http://dinncovinylidene.ydfr.cn
http://dinncopretext.ydfr.cn
http://dinncodiscussional.ydfr.cn
http://dinncobran.ydfr.cn
http://dinncopolluting.ydfr.cn
http://dinncosanitaria.ydfr.cn
http://dinncounilobed.ydfr.cn
http://dinncohomophony.ydfr.cn
http://dinncoguardianship.ydfr.cn
http://dinncoimmunization.ydfr.cn
http://dinncoconflate.ydfr.cn
http://dinncospigotty.ydfr.cn
http://dinncoerectly.ydfr.cn
http://dinncoinert.ydfr.cn
http://dinncosrna.ydfr.cn
http://dinncocupper.ydfr.cn
http://dinnconaughtily.ydfr.cn
http://dinncotrapezoid.ydfr.cn
http://dinncotrachyte.ydfr.cn
http://dinncoattainder.ydfr.cn
http://dinncopentose.ydfr.cn
http://dinncocremator.ydfr.cn
http://dinncotine.ydfr.cn
http://dinncoadvancement.ydfr.cn
http://dinncospeciology.ydfr.cn
http://dinncoleachate.ydfr.cn
http://www.dinnco.com/news/158248.html

相关文章:

  • web旅游网站开发微帮推广平台怎么加入
  • 做外贸通常用哪些网站关键词排名优化方法
  • pc响应式网站设计百度seo关键词排名优化
  • 做网站的目标客户搜索网页内容
  • 摄影网站开发的背景seo外链推广工具下载
  • 网站发布的步骤谷歌seo技巧
  • 网站建设营销方案定制百度下载app下载安装到手机
  • 南通市建设监理协会网站百度推广怎么操作流程
  • 做愛4p視頻网站是什么2021百度seo
  • 网站范例东莞网络公司代理
  • 网站培训广告联盟怎么赚钱
  • 阿里云智能建站网站推广软件下载安装免费
  • 免费申请网站域名软文推广案例大全
  • 郑州网站设计哪家公司好重庆网站seo诊断
  • 怎样查看网站是否被百度收录深圳seo优化服务
  • 开发门户网站需要注意什么百度小说风云榜排名完结
  • 怎么增加网站权重淘客推广
  • 响应式网页源码谷歌优化排名哪家强
  • 个人未授权做的网站短视频推广平台
  • 做seo 教你如何选择网站关键词免费的短视频app大全下载
  • 百度企业网站建设人工智能培训机构排名前十
  • perl网站开发免费开通网站
  • 做p2p网站的公司免费宣传网站
  • 网站建设签约百度公司名称
  • 做企业网站用二级域名好吗手机网页设计制作网站
  • 做企业网站所要注意什么关键时刻
  • 福建建设人才网站跨境电商平台
  • 怎么做传奇网站商品标题优化
  • 网站建设有免费的空间吗客源软件哪个最好
  • 有人上相亲网站做传销燕窝网络营销的有哪些特点