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

做一视频网站多少钱新手跨境电商怎么做

做一视频网站多少钱,新手跨境电商怎么做,上海企业网站优化,做的好点的外贸网站有哪些即同一个方法可以根据发送对象的不同而采用多种不同的行为方式。 一个对象的实际类型是确定的#xff0c;但可以指向对象的引用的类型有很多#xff08;父类#xff0c;有关系的类#xff09;。 多态存在的条件#xff1a; 1. 有继承关系#xff1b; 2. 子类重写父类…· 即同一个方法可以根据发送对象的不同而采用多种不同的行为方式。 · 一个对象的实际类型是确定的但可以指向对象的引用的类型有很多父类有关系的类。 · 多态存在的条件 1. 有继承关系 2. 子类重写父类的方法 3. 父类引用指向子类对象。 多态注意事项   1. 多条是方法的多态属性没有多态 2. 父类和子类有联系    类型转换异常ClassCastException 注意以下方法没有多态   1. static方法属于类不属于实例所以该方法不能被重写 2. final  常量无法重写 3. private方法  私有无法重写。 代码演示 public class Person {public void run(){System.out.println(run);} }public class Student extends Person{Overridepublic void run() {System.out.println(son);}public void eat(){System.out.println(eat);} } import oop.demo06.Person; import oop.demo06.Student; //一个项目应该只存在一个main方法 public class Application {public static void main(String[] args) {//一个对象的实际类型是确定的//new Student();//new Person();//可以指向的引用类型就不确定了:父类的引用指向子类//Student子类能调用的方法都是自己的或者继承父类的Student S1 new Student();//Person父类可以指向子类但是不能调用子类独有的方法Person S2 new Student();Object S3 new Student();//对象能执行哪些方法主要看对象左边的类型和右边关系不大S2.run(); //子类重写了父类的方法就执行子类的方法S1.run();//想调用的话用强制转换((Student) S2).eat();} } instanceof类型转换 instanceof关键字判断一个对象是什么类型 创建一个父类Person子类Student、Teacher 代码演示 public static void main(String[] args) {//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); 编译报错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); 编译报错//System.out.println(student instanceof String); 编译报错} 类型转换 1. 父类引用指向子类的对象 2. 把子类转换为父类向上转型可能丢失一些方法 3. 把父类转换为子类向下转型强制转换 4. 方便方法的调用减少重复的代码。简洁 代码演示父类、子类同上 //类型之间的转换父 子//高 低Person obj new Student();//将上面的对象转换为Student类型就可以使用Student的方法了Student student (Student) obj;student.go();//或((Student) obj).go();//低 高//子类转换为父类可能会丢失自己的一些方法Student student1 new Student();student1.go();Person person student1;
http://www.dnsts.com.cn/news/27933.html

相关文章:

  • 5000元做网站值么重庆网站设计费用
  • 网站建设及优化方案社交网站建设内容
  • 网站建设个人简历如何统计网站访问量
  • 网站的新闻模块怎么做wordpress虚拟商品销售
  • 网站建设哪家专业外包制作app
  • 科迪兔网站建设网络公司排名哪家专业
  • 哪个网站可以接程序项目来做wordpress地图
  • 免费建筑设计素材网站做网站的职位叫什么
  • html5响应式网站济南网络推广公司
  • 长沙做个网站多少钱商城网站建设
  • 让别人做网站应注意什么网站建设优劣势分析
  • 网站 数据库选择重庆建设网站首页
  • 网站title优化tomcat做网站
  • 怎么看网站哪个公司做的房地产微网站模板
  • 晋城网站设计wordpress免回复
  • 我们公司在做网站推广代帮企业做网站
  • 搭建微信网站怎么做制作一个网站需要多久
  • 网站设计 素材电子企业网络推广方案
  • wordpress全站加密做网站要建立站点吗
  • 克拉玛依市建设局网站麻城建设局网站停办
  • 信誉好的赣州网站建设网络服务能力
  • 常州低价网站建设公司做理财网站
  • 浙江省建设厅网站查询为什么点不开网站
  • 单位建设网站注意点沅江网站开发
  • 长春网站建设公司十佳海口网站制作公司
  • html用表格来做网站布局优化教程网下载
  • 工作总结加强部门网站建设学生做网站的软件
  • 泰州网站制作专业郑州做花店网站
  • 北京网站关键字优化百度 seo 工具
  • 郑州做网站和域名使页面具有动态效果的网站建设技术