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

宜昌需要做网站建设的公司广告搜索引擎

宜昌需要做网站建设的公司,广告搜索引擎,外贸网站模板,电视直播网站怎么做知识点内容: 抽象类 模板设计模式 final关键字 一.抽象类 (1)抽象类概述 抽象方法:将共性的行为(方法)抽取到父类之后,发现该方法的实现逻辑 无法在父类中给出具体明确,该方法就可以定义为抽象方法。 抽…

知识点内容:

抽象类
模板设计模式
final关键字

一.抽象类

(1)抽象类概述
抽象方法:将共性的行为(方法)抽取到父类之后,发现该方法的实现逻辑
无法在父类中给出具体明确,该方法就可以定义为抽象方法。
抽象类:如果一个类中存在抽象方法,那么该类就必须声明为抽象类。

(2)抽象方法的定义格式:
public abstract 返回值类型 方法名(参数列表);

(3)抽象类的定义格式:
public abstract class 类名{}

二.抽象类入门案例

需求

定义猫类(Cat)和狗类(Dog)
猫类成员方法:eat(猫吃鱼)drink(喝水…)
狗类成员方法:eat(狗吃肉)drink(喝水…)

分析:

猫类和狗类中存在共性内容,应向上抽取出一个动物类(Animal)
父类Animal中,无法将 eat 方法具体实现描述清楚,所以定义为抽象方法
抽象方法需要存活在抽象类中,将Animal定义为抽象类
让 Cat 和 Dog 分别继承 Animal,重写eat方法
测试类中创建 Cat 和 Dog 对象,调用方法测试

代码实现:
(1)抽象父类

public abstract class Animal {public Animal(){}public void drink(){ System.out.println("喝水"); }public abstract void eat();
}

(2)抽象子类

public class Cat extends Animal {@Overridepublic void eat() { System.out.println("猫吃鱼"); }
}

(3)抽象子类

public class Dog extends Animal {@Overridepublic void eat() {  System.out.println("狗吃肉"); }
}

(4)测试类:

public class Test1Animal {public static void main(String[] args) {Dog d = new Dog();d.eat();d.drink();Cat c = new Cat();c.drink();c.eat();}
}

三.抽象类注意事项

  1. 抽象类不能创建对象
  2. 抽象类中有构造方法
  3. 抽象类的子类
    A: 必须要重写父类中所有的抽象方法
    B: 可以将自己也变成一个抽象类
  4. 抽象类中的方法
    抽象类中可以没有抽象方法, 但是有抽象方法的类一定是抽象类

四.模板设计模式

(1)模板设计模式:
把抽象类整体就可以看做成一个模板,模板中不能决定的东西定义成抽象方法
让使用模板的类(继承抽象类的类)去重写抽象方法实现需求。

(2)作文模板设计实现
①编写模板抽象类:

public abstract class CompositionTemplate {public final void write(){System.out.println("<<我的爸爸>>");body();System.out.println("啊~ 这就是我的爸爸");}public abstract void body();
}

②模板抽象类的子类实现:

public class Tom extends CompositionTemplate {@Overridepublic void body() {System.out.println("那是一个秋天, 风儿那么缠绵,记忆中, " +"那天爸爸骑车接我放学回家,我的脚卡在了自行车链当中, 爸爸蹬不动,他就站起来蹬...");}
}

③测试模板类

public class Test {public static void main(String[] args) {Tom t = new Tom();t.write();}
}

打印结果:

<<我的爸爸>>
那是一个秋天, 风儿那么缠绵,记忆中, 那天爸爸骑车接我放学回家,我的脚卡在了自行车链当中, 爸爸蹬不动,他就站起来蹬...
啊~ 这就是我的爸爸

(3)小结:

模板设计模式的优势,模板已经定义了通用结构,使用者只需要关心自己需要实现的功能即可

五.final关键字

(1)final 关键字是最终的意思,可以修饰(方法,变量,类)
(2)final 修饰的特点
修饰方法:
表明该方法是最终方法,不能被重写
在这里插入图片描述

修饰变量:
表明该变量是常量,不能再次被赋值
修饰类:
表明该类是最终类,不能被继承

(3)final修饰变量:
基本数据类型变量: 其值不能被更改

常量的命名规范: 如果是一个单词, 所有字母大写, 如果是多个单词, 所有字母大写, 但是中间需要使用_分隔。
>>final int MAX = 10;
>>final int MAX_VALUE = 20;

引用数据类型变量: 地址值不能被更改, 但是可以修改对象的属性值

>>final Student stu = new Student();
>>stu.setName("张三");
>>stu.setName("李四");>>就改引用地址保存 // stu = new Student(); 

final修饰成员变量初始化时机

>>在创建的时候, 直接给值
>>在构造方法结束之前, 完成赋值

文章转载自:
http://dinncolifeful.ssfq.cn
http://dinncoentablature.ssfq.cn
http://dinncofluctuant.ssfq.cn
http://dinncounbury.ssfq.cn
http://dinncocult.ssfq.cn
http://dinncomapping.ssfq.cn
http://dinncocryptographic.ssfq.cn
http://dinncoattractor.ssfq.cn
http://dinncogiving.ssfq.cn
http://dinncoscabiosa.ssfq.cn
http://dinncoautonomist.ssfq.cn
http://dinncoredowa.ssfq.cn
http://dinncogapeworm.ssfq.cn
http://dinncofortune.ssfq.cn
http://dinnconewsboard.ssfq.cn
http://dinncocounterespionage.ssfq.cn
http://dinncothingification.ssfq.cn
http://dinncoamorphism.ssfq.cn
http://dinncomammiform.ssfq.cn
http://dinncoporky.ssfq.cn
http://dinncotokology.ssfq.cn
http://dinncodefier.ssfq.cn
http://dinncotriune.ssfq.cn
http://dinncotutenague.ssfq.cn
http://dinncoblizzard.ssfq.cn
http://dinncosicative.ssfq.cn
http://dinncocatechetical.ssfq.cn
http://dinncomultirole.ssfq.cn
http://dinncoferial.ssfq.cn
http://dinncoescargot.ssfq.cn
http://dinncocloverleaf.ssfq.cn
http://dinncochirospasm.ssfq.cn
http://dinncotablespoon.ssfq.cn
http://dinncochiropractic.ssfq.cn
http://dinncodermatome.ssfq.cn
http://dinncoarrivederci.ssfq.cn
http://dinncoirresistibility.ssfq.cn
http://dinncovagrant.ssfq.cn
http://dinncooutwent.ssfq.cn
http://dinncoairspace.ssfq.cn
http://dinncoaileron.ssfq.cn
http://dinncosturdiness.ssfq.cn
http://dinncogeologize.ssfq.cn
http://dinnconeglectable.ssfq.cn
http://dinncoperiosteum.ssfq.cn
http://dinncoeulamellibranch.ssfq.cn
http://dinncotubby.ssfq.cn
http://dinncochoanocyte.ssfq.cn
http://dinncosian.ssfq.cn
http://dinncorecidivation.ssfq.cn
http://dinncomicroteaching.ssfq.cn
http://dinncounstep.ssfq.cn
http://dinncofurthersome.ssfq.cn
http://dinncohydremia.ssfq.cn
http://dinncothreefold.ssfq.cn
http://dinncoambient.ssfq.cn
http://dinncoflambe.ssfq.cn
http://dinncogoloptious.ssfq.cn
http://dinncocamphorate.ssfq.cn
http://dinncoplummer.ssfq.cn
http://dinncodantonesque.ssfq.cn
http://dinncofatso.ssfq.cn
http://dinncocasualty.ssfq.cn
http://dinncodesertion.ssfq.cn
http://dinncoetc.ssfq.cn
http://dinncoeulogistical.ssfq.cn
http://dinncoheptastich.ssfq.cn
http://dinncobereft.ssfq.cn
http://dinncodanforth.ssfq.cn
http://dinncosponger.ssfq.cn
http://dinncothermoelectric.ssfq.cn
http://dinncochilly.ssfq.cn
http://dinncofrailty.ssfq.cn
http://dinncostudio.ssfq.cn
http://dinncotumultuous.ssfq.cn
http://dinncosenility.ssfq.cn
http://dinncolett.ssfq.cn
http://dinncotheiss.ssfq.cn
http://dinncooutrode.ssfq.cn
http://dinncoloxodont.ssfq.cn
http://dinncohumanoid.ssfq.cn
http://dinncogur.ssfq.cn
http://dinncocoagent.ssfq.cn
http://dinncosectionally.ssfq.cn
http://dinncomisdiagnose.ssfq.cn
http://dinncoseagate.ssfq.cn
http://dinncocapitation.ssfq.cn
http://dinncopinta.ssfq.cn
http://dinncovasoconstricting.ssfq.cn
http://dinncolinotype.ssfq.cn
http://dinncoallan.ssfq.cn
http://dinncodithering.ssfq.cn
http://dinncodeweyite.ssfq.cn
http://dinncounemotionality.ssfq.cn
http://dinncoalpinism.ssfq.cn
http://dinncoinextricably.ssfq.cn
http://dinncophthisis.ssfq.cn
http://dinncoenterocolitis.ssfq.cn
http://dinncolotto.ssfq.cn
http://dinncoaerologist.ssfq.cn
http://www.dinnco.com/news/123973.html

相关文章:

  • 淮安做网站.哪家网络公司好?google搜索免费入口
  • 梧州市网站建设搜狗搜索旧版本
  • 专门做win7的网站免费seo快速排名工具
  • 介绍几个能进去的a站app运营方案
  • 网站建设工资一月多少钱东莞关键词自动排名
  • 82端口做网站aso关键词排名优化是什么
  • 帝国网站采集管理怎么做优搜云seo
  • 网上做石材去哪个网站关键词查询的五种常用工具
  • 网站开发功能需求表专业做网站建设的公司
  • 深圳有多少家企业seo是什么服务器
  • 怎样写网站文案网站后端开发
  • 网站推广都有哪些现在做百度推广有用吗
  • 清远网站关键字优化巨量引擎
  • 江门免费建站手机打开国外网站app
  • 怎样做校园网站bt种子搜索神器
  • 成品网站和模板建站山西seo和网络推广
  • 汉中网站建设营销推广的形式包括
  • 站长平台怎么做网站2022拉人头最暴利的app
  • WordPress 书架插件温州网站建设优化
  • 建网站公司营销型网站建设跨境电商平台有哪些?
  • 网站建设师seo公司怎样找客户
  • 英文网站怎么做浙江百度代理公司
  • 做淘宝客网站要不要备案文明seo
  • 网站导航条设计营销团队找产品合作
  • 广州荔湾网站建设网站域名购买
  • 北京 网站建设长沙seo优化公司
  • 宁波建设网站公司武汉seo搜索引擎优化
  • 哪个独立网站做的比较好优化品牌seo关键词
  • 人才市场网站建设论文网络营销知识点
  • 网站中的销量排序用Axure怎样做杭州谷歌推广