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

企业网站建设门户影视传媒网站源码

企业网站建设门户,影视传媒网站源码,软件技术好就业吗,网站做跳转会有什么影响多态 即同一个方法可以根据发送对象的不同而采用多种不同的行为方式一个对象的实际类型是确定的#xff0c;按可以指向对象的引用类型有很多多态存在的条件#xff1a; 有继承关系子类重写父类的方法父类引用指向子类对象 注意#xff1a;多态是方法的多态#xff0c;属性…多态 即同一个方法可以根据发送对象的不同而采用多种不同的行为方式一个对象的实际类型是确定的按可以指向对象的引用类型有很多多态存在的条件 有继承关系子类重写父类的方法父类引用指向子类对象 注意多态是方法的多态属性没有多态instanceof 父类 package com.mypackage.oop.demo08;public class Person08 {public void run(){System.out.println(run);} }/* 多态注意事项 1.多态是方法的多态属性没有多态 2.父类和子类之间才能强制转换否则会有类型转换异常 ClassCastException 3.存在条件继承关系父类引用指向子类对象不可重写的方法1.static 静态方法 属于类 不属于实例2.final 常量3.private 私有*/子类 package com.mypackage.oop.demo08;public class Student08 extends Person08 {Overridepublic void run(){System.out.println(son);}public void eat(){System.out.println(eat);} }应用 package com.mypackage.oop.demo08;public class Application08 {public static void main(String[] args) {//一个对象的实际类型是确定的new Student08();new Person08();//但对象可以指向的引用类型就不确定了Student08 s1 new Student08();Person08 s2 new Student08(); //父类的引用指向子类的类型Object s3 new Student08();Person08 p1 new Person08(); //父类的引用指向自己//对象能执行哪些方法主要看的是等号左边的类型s2.run(); //son//s2.eat(); //会报错//父类虽然可以指向子类但是不能调用子类独有的方法((Student08)s2).eat(); //进行强制性转换高转低父转子不能同级之间进行类型转换 //eats1.eat(); //eats1.run(); //sonp1.run(); //run} } instanceof 用于判断一个对象是什么类型判断两个对象是否具有父子关系 package com.mypackage.oop.demo09;public class Application09 {public static void main(String[] args) {//Object String//Object Person Teacher//Object Person StudentObject object new Student();System.out.println(object instanceof Student); //trueSystem.out.println(object instanceof Person); //trueSystem.out.println(object instanceof Object); //trueSystem.out.println(object instanceof Teacher); //falseSystem.out.println(object instanceof String); //falseSystem.out.println();Person person new Student();System.out.println(person instanceof Student); //trueSystem.out.println(person instanceof Person); //trueSystem.out.println(person instanceof Object); //trueSystem.out.println(person instanceof Teacher); //false//System.out.println(person instanceof String); //编译即报错因为Person和String是无继承关系的不能进行类型比较System.out.println();Student student new Student();System.out.println(student instanceof Student); //trueSystem.out.println(student instanceof Person); //trueSystem.out.println(student instanceof Object); //true//System.out.println(student instanceof Teacher); //编译即报错因为Student和Teacher是无继承关系的//System.out.println(person instanceof String); //编译即报错因为Student和String是无继承关系的System.out.println();Object object2 new Person();System.out.println(object2 instanceof Student); //false 因为person比student大System.out.println(object2 instanceof Person); //trueSystem.out.println(object2 instanceof Object); //trueSystem.out.println(object2 instanceof Teacher); //false 因为person比teacher大System.out.println(object2 instanceof String); //false//只要等号左边的类型没有父子关系就会编译错误//等号左边的类型有父子关系右边的类型无父子关系或者父在instanceof前就会输出false/*类型之间的转换基本类型的转换 类型的高低父 子 强制转换方式与基本类型的强制转换方式一样前面加个括号写上要转换成的类型父类转为子类没什么影响因为基本上父类的方法子类都有。但子类转换为父类可能会丢失一些子类本有的方法*///父类引用可以指向子类子类引用不可以指向父类} }
http://www.zqtcl.cn/news/429551/

相关文章:

  • 电大企业网站建设论文范文搜狗推广登录入口
  • 建设银行u盾用网站打不开软件工程师证书有哪些
  • 网站建设域名的购买多少钱注册的公司才能参加投标
  • 做婚纱网站策划方案php网站超市源码
  • 济南网站搭建公司有哪些做企业网站的
  • 360做企业网站多少钱凡客诚品网
  • 效果好的徐州网站建设LAMP环境wordpress放在哪里
  • 考试类网站如何做什么是网络营销?有何特点
  • 网站制作公司哪家好wordpress插件怎么汉化
  • 南阳东莞网站建设公司网页升级访问狼在线观看
  • 备案的网站每年都要备案么东平县建设局网站
  • 做网站必须得ipc手机网站制作方法
  • 山东省建设监理协会网站打不开移动互联网开发实践
  • 南宁微网站制作需要多少钱小米商城网站开发文档
  • 制作销售网站有哪些如何制作个人网页设计
  • 新网站做内链智能网站推广软件
  • 西宁市住房和城乡建设局网站广州站是指哪个站
  • 帮建网站网页设计师考试内容
  • seo网站开发txt 发布 wordpress
  • 资讯门户类网站模板定制系统开发公司
  • 让网站快速收录初中毕业如何提升学历
  • 石家庄做网站价格seo优化效果
  • 为什么浏览器打开是2345网址导航seo免费资源大全
  • 网站工程是干啥的动态个人网页制作html教程
  • 阿里云多网站建设wordpress 统计分析
  • 长沙网站定制公司科技特长生
  • 查公司的口碑和评价的网站中学生怎么做网站
  • 做网站买空间多少钱深圳seo优化公司
  • 中国建设银行北京市互联网网站wordpress商城购物表单
  • 万网网站备案管理查询工程建设项目的网站