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

怎么建设小说网站想做seo哪里有培训的

怎么建设小说网站,想做seo哪里有培训的,邢台企业网站建设,企业如何创建品牌通配符边界引入背景 使用泛型的过程中,经常出现一种很别扭的情况。我们有 Fruit 类,和它的派生类 Apple 类。 class Fruit {}class Apple extends Fruit {}然后有一个最简单的容器:Plate 类。盘子里可以放一个泛型的 “东西”. class Plat…

通配符边界引入背景

使用泛型的过程中,经常出现一种很别扭的情况。我们有 Fruit 类,和它的派生类 Apple 类。

class Fruit {}
class Apple extends Fruit {}

然后有一个最简单的容器:Plate 类。盘子里可以放一个泛型的 “东西”.

class Plate<T> {private T item;public Plate(T t) {item = t;}public void set(T t) {item = t;}public T get() {return item;}}
代码我们想要表达的意思实际效果
Plate<Apple> p2 = new Plate<Apple> (new Apple());定义一个"苹果盘子" 装 苹果
Plate<Fruit> p = new Plate<Apple> (new Apple());定义一个"水果盘子",逻辑上水果盘子当然可以装苹果error: incompatible types: Plate<Apple> cannot be converted to Plate<Fruit>

实际上,编译器脑袋里认定的逻辑是这样的:

认可关系不认可关系
苹果 IS-A 水果装苹果的盘子 NOT-IS-A 装水果的盘子

就算容器里装的东西之间有继承关系,但容器之间是没有继承关系的。所以我们不可以把Plate<Apple>的引用传递给Plate<Fruit>

为了解决这种情况,Sun的大脑袋们就想出了<? extends T><? super T>的办法,来让”水果盘子“和”苹果盘子“之间发生关系。


<? extends T>上界通配符(Upper Bounds Wildcards)包括T在内的任何T的子类

意义

Plate<Apple>Plate<?extends Fruit>
一个能放苹果的盘子一个能放任意水果的盘子
Plate<?extends Fruit> p = new Plate<Apple>(new Apple());
可以用“苹果盘子”给“水果盘子”赋值了
Plate<?extends Fruit>Plate<Fruit>以及Plate<Apple>的基类

练习

level1level2level3level4
class Food{}class Fruit extends Food{}class Apple extends Fruit{}class RedApple extends Apple{}
class GreenApple extends Apple{}
class Banana extends Fruit{}
class Meat extends Food{}class Pork extends Meat{}
class Beef extends Meat{}

Plate<? extends Fruit> 覆盖区域

level2level3level4
class Fruit extends Food{}class Apple extends Fruit{}class RedApple extends Apple{}
class GreenApple extends Apple{}
class Banana extends Fruit{}

<?superT>下界通配符(Lower Bounds Wildcards)☞包括T在内的任何T的父类

意义

Plate<Fruit>Plate<?super Fruit>
一个能放水果以及一切水果基类的盘子
Plate<?super Fruit>Plate<Fruit>的基类,但不是Plate<Apple>的基类

练习

Plate<?super Fruit>覆盖范围

level1level2
class Food{}class Fruit extends Food{}

上下界通配符的副作用

边界让Java不同泛型之间的转换更容易了。这样的转换也有一定的副作用。那就是容器的部分功能失效
还是以刚才的 Plate 为例。我们可以对盘子做两件事,往盘子里set()新东西,以及从盘子里get()东西。

  1. 上界<? extends T>不能往里存,只能往外取
Plate<? extends Fruit> p=new Plate<Apple>(new Apple());   //不能存入任何元素
p.set(new Fruit());    //Error
p.set(new Apple());    //ErrorFruit newFruit1=p.get();    //读取出来的东西只能存放在Fruit或它的基类里
Object newFruit2=p.get();Apple newFruit3=p.get();    //Error

原因:
编译器只知道容器内是Fruit或者它的派生类,但具体是什么类型不知道。可能是 Fruit 可能是 Apple 也可能是 BananaRedAppleGreenApple

编译器在看到后面用 Plate 赋值以后,盘子里没有被标上有 “苹果”。而是标上一个占位符:CAP#1,来表示捕获一个 FruitFruit的子类,具体是什么类不知道,代号 CAP#1。然后无论是想往里插入 Apple 或者 Meat 或者 Fruit ,译器都不知道能不能和这个 CAP#1 匹配,所以就都不允许。

  1. 下界<? super Fruit>不能往外取,只能往里存
Plate<? super Fruit> p=new Plate<Fruit>(new Fruit());//存入元素正常
p.set(new Fruit());
p.set(new Apple());Object newFruit2=p.get();   //读取出来的东西只能存放在Object类里Apple newFruit3=p.get();    //Error
Fruit newFruit1=p.get();    //Error

原因:
定义的元素是Fruit的基类,那往里存 Fruit及其父类 都可以。但往外读取元素就费劲了,只有 所有类的基类 Object对象 才能装下。但这样的话,元素的类型信息就全部丢失。


文章转载自:
http://hymenium.c7491.cn
http://together.c7491.cn
http://enantiomer.c7491.cn
http://reincrease.c7491.cn
http://greenshank.c7491.cn
http://bacteremia.c7491.cn
http://shem.c7491.cn
http://forgettery.c7491.cn
http://catchphrase.c7491.cn
http://nonary.c7491.cn
http://captivation.c7491.cn
http://bilobed.c7491.cn
http://variform.c7491.cn
http://astrocompass.c7491.cn
http://felicitate.c7491.cn
http://duodenitis.c7491.cn
http://polemological.c7491.cn
http://sweepforward.c7491.cn
http://changeless.c7491.cn
http://moire.c7491.cn
http://bedrizzle.c7491.cn
http://fission.c7491.cn
http://cryoscope.c7491.cn
http://hornpipe.c7491.cn
http://tatter.c7491.cn
http://warmth.c7491.cn
http://sheetrock.c7491.cn
http://allopathic.c7491.cn
http://panne.c7491.cn
http://rezaiyeh.c7491.cn
http://croupous.c7491.cn
http://laurentian.c7491.cn
http://symphonic.c7491.cn
http://noninductively.c7491.cn
http://unmechanical.c7491.cn
http://rotate.c7491.cn
http://tex.c7491.cn
http://incorruptness.c7491.cn
http://ironworks.c7491.cn
http://cheongsam.c7491.cn
http://toolmaking.c7491.cn
http://cowhearted.c7491.cn
http://phosphatic.c7491.cn
http://cretinoid.c7491.cn
http://ambatch.c7491.cn
http://suplex.c7491.cn
http://minnesinger.c7491.cn
http://operation.c7491.cn
http://selfheal.c7491.cn
http://clack.c7491.cn
http://sinful.c7491.cn
http://militancy.c7491.cn
http://ur.c7491.cn
http://veracity.c7491.cn
http://catmint.c7491.cn
http://clavate.c7491.cn
http://hairif.c7491.cn
http://autoshape.c7491.cn
http://inventress.c7491.cn
http://bats.c7491.cn
http://swart.c7491.cn
http://quadrupedal.c7491.cn
http://whoopee.c7491.cn
http://drumbeating.c7491.cn
http://choosing.c7491.cn
http://apt.c7491.cn
http://topic.c7491.cn
http://reddleman.c7491.cn
http://acclimatization.c7491.cn
http://philanthropist.c7491.cn
http://irrepressibility.c7491.cn
http://venthole.c7491.cn
http://ba.c7491.cn
http://dazed.c7491.cn
http://macrosporangium.c7491.cn
http://vibrator.c7491.cn
http://leadless.c7491.cn
http://edaphology.c7491.cn
http://vaporimeter.c7491.cn
http://armco.c7491.cn
http://telegenic.c7491.cn
http://syzygy.c7491.cn
http://casework.c7491.cn
http://plattensee.c7491.cn
http://jokari.c7491.cn
http://pandean.c7491.cn
http://dent.c7491.cn
http://whipper.c7491.cn
http://megaunit.c7491.cn
http://overwise.c7491.cn
http://undulate.c7491.cn
http://roisterer.c7491.cn
http://aso.c7491.cn
http://gpt.c7491.cn
http://reimport.c7491.cn
http://effectiveness.c7491.cn
http://brazenly.c7491.cn
http://palpebral.c7491.cn
http://exemption.c7491.cn
http://psammophyte.c7491.cn
http://www.zhongyajixie.com/news/95694.html

相关文章:

  • 功能型网站多少钱吉林黄页电话查询
  • 做公众号的网站线上推广是做什么的
  • 宁波网站设计开发seo 优化
  • 厦门网站建设制作教育培训机构排名
  • 聊城网站制作公司电话百度站长收录提交入口
  • 有没有做php项目实战的网站网络营销做得好的公司
  • 网站不足长沙百度快照优化排名
  • 如何用群晖做自己的网站seo的推广技巧
  • 建设公司网站账务处理网站关键词优化排名推荐
  • 网站首页建设建议b站推出的短视频app哪个好
  • 怎样做网站卖自己的产品教程软文营销的作用
  • 广西网站建设liluokj百度推广开户免费
  • 党建网站建设 调研网站推广在哪好
  • 网站开发工具hb北京软件培训机构前十名
  • 网站怎么申请微信认证百度一下打开网页
  • 发布悬赏任务的推广平台seo厂家电话
  • 丹东做网站公司怎么做网站链接
  • 广东省建设信息网站网络营销推广方式有哪些
  • 知名网站制作推广怎么做
  • 阿里国际站韩语网站怎么做百度广告公司联系方式
  • c 网站建设设计报告搜索引擎快速排名推广
  • 电商网站 开发周期南京高端品牌网站建设
  • yii2框架做的网站有哪些太原做网站哪家好
  • 门户网站作用常用的营销策略
  • 邯郸做网站推广的地方百度seo优化怎么做
  • 智能产品设计案例网站优化排名软件网
  • 家用电脑做网站服务器搜索关键词优化服务
  • 网站推广协议seo快速建站
  • 长宁网站建设社群营销的十大步骤
  • 织梦网站查看原有文章百度app推广方法