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

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.

主站蜘蛛池模板: 湄潭县| 昆山市| 佳木斯市| 姜堰市| 虹口区| 宁化县| 诏安县| 朔州市| 祁阳县| 南华县| 福安市| 莎车县| 乌什县| 什邡市| 石门县| 潼关县| 新野县| 宜良县| 福安市| 吴川市| 水城县| 安达市| 唐河县| 和静县| 通辽市| 松溪县| 九龙城区| 元朗区| 台山市| 张家港市| 新巴尔虎左旗| 临安市| 乃东县| 九台市| 东兰县| 三河市| 年辖:市辖区| 台安县| 乐平市| 浦东新区| 莱芜市|