官术网_书友最值得收藏!

Type casting

Type casting is a way to check the type of an instance and/or deal with that instance as if it is a different superclass or subclass from somewhere else in its class hierarchy. There are two types of operator to check and cast types as the following:

  • Type check operator (is): This checks whether an instance is of a definite subclass type.
  • Type cast operator (as and as?): A constant or variable of a definite class type may refer to an instance of a subclass under the hood. If this is the case, we can try to downcast it to the subclass type with as.

Type safety, type inference, annotation, aliases and type casting will be covered in detail in Chapter 3, Types and Type Casting.

主站蜘蛛池模板: 连南| 个旧市| 仪征市| 浙江省| 定远县| 双桥区| 张掖市| 乌拉特前旗| 临夏市| 贡山| 东城区| 武乡县| 化德县| 买车| 长顺县| 曲阳县| 鄂托克旗| 新疆| 台南市| 大安市| 长阳| 扶绥县| 曲沃县| 紫金县| 西青区| 罗山县| 西和县| 竹北市| 太保市| 怀化市| 兴海县| 芜湖县| 合江县| 绥芬河市| 阿拉善右旗| 泰宁县| 建水县| 商城县| 华容县| 靖安县| 高平市|