当前位置:网站首页>2021-05-11 instanceof and type conversion
2021-05-11 instanceof and type conversion
2022-06-23 10:07:00 【Deer like deer】
public class Application {
public static void main(String[]args){
Object object = new Student();
System.out.println(object instanceof Student);
System.out.println(object instanceof Person);
System.out.println(object instanceof Object);
System.out.println(object instanceof Teacher);
System.out.println(object instanceof String);
// Conversion between types : Father Son
// high low
Person obj = new Student();
//student Convert this object to Student type , We can use Student Type of method
Student student = (Student) obj;
student.go();
//==((Student)obj).go();
// The subclass is converted to a parent class , You may lose some of your original methods
Student student1 = new Student();
student.go();
Person person = student1;
}
}
- Parent class reference refers to the object of the parent class
- Convert a subclass to a parent , Upward transformation
- Convert a parent class to a child class , Move down : Coercive transformation
- Convenient method call , Reduce duplicate code , concise
- abstract : encapsulation Inherit polymorphic
边栏推荐
- [GXYCTF2019]BabySQli
- IPv6 的速度比 IPv4 更快?
- 同花顺推荐么?手机开户安全么?
- Tencent tangdaosheng: practice "science and technology for the good" and promote sustainable social value innovation
- 数值计算方法
- 陆奇首次出手投资量子计算
- thymeleaf如何取url中请求参数值?
- AI系统前沿动态第38期:谷歌已放弃TensorFlow?;训练大模型的四种GPU并行策略;LLVM之父:模块化设计决定AI前途
- 135,137,138,445禁用导致无法远程连接数据库
- 分布式锁的三种实现方式
猜你喜欢

RPC kernel details you must know (worth collecting)!!!

RT thread add MSH command

ICLR 2022 | 视频中的动态卷积TAdaConv以及高效的卷积视频理解模型TAdaConvNeXt

Go string comparison

Golang 快速上手 (3)

Golang 快速上手 (1)

文件IO(1)

oracle中遇到的bug

ICLR 2022 | dynamic convolution tadaconv in video and efficient convolution video understanding model tadaconvnext

Liujinhai, architect of zhongang Mining: lithium battery opens up a Xintiandi for fluorine chemical industry
随机推荐
高性能算力中心 — NVMe/NVMe-oF — NVMe-oF Overview
Comic | code review is driving me crazy!
Centre de calcul haute performance - nvme / nvme - of - nvme - of overview
Liujinhai, architect of zhongang Mining: lithium battery opens up a Xintiandi for fluorine chemical industry
太阳塔科技招聘PostgreSQL数据库工程师
sql编写问题,求出当月和上月的环比值
数学分析_笔记_第2章:实数与复数
The second Tencent light · public welfare innovation challenge was launched, and the three competition topics focused on the social value of sustainable development
JS教程之 什么是 JSX?为什么我们需要它?
IPv6 的速度比 IPv4 更快?
陆奇首次出手投资量子计算
Successful experience in postgraduate entrance examination for MTI master of English translation major of Beijing University of science and technology in 2023
基於STM32設計的寵物投喂器
2021-04-16方法重载 传参
Lying trough, the most amazing paper artifact!
sql根据比较日期新建字段
Go语言JSON 处理
高性能算力中心 — RDMA — 实现技术
同花顺推荐么?手机开户安全么?
基于STM32设计的宠物投喂器