Issue about casting object brackets

前端 未结 6 622
無奈伤痛
無奈伤痛 2020-12-21 01:13

I have noticed that there are two ways to cast objects (the difference is the placement of the outer parenthesis):

 1. SimpleType simpleType = ((SimpleType)          


        
6条回答
  •  太阳男子
    2020-12-21 01:49

    They are entirely doing diffrent things. they are not same at all.

     1. SimpleType simpleTypee = ((SimpleType) (property.getType()));
    

    This first invokes getType of property and then casts the returned Object to SimpleType

     2. SimpleType simpletype = ((SimpleType) property).getType();
    

    This first casts the property to SimpleType and then invokes getType on the SimpleType

提交回复
热议问题