android - Why are parentheses used when declaring a textview -
i'm new android. i've got experience c# , java can't figure out.
i know how use it. i've written couple apps already. it's simple don't understand this. why (textview) in parentheses.
i've searched sdk documentation , afaik doesn't mention this.
textview example = (textview) findviewbyid(r.id.example);
this explict cast, findviewbyid() returns more generic type view.
the convention c, , used in c++, , in case, java. vb.net , other basic variants have ctype(), or cast(). stongly typed languages have similar mechanism explicitly convert between types in compatible way. note that, in example, not returned findviewbyid() can safely cast textview type.
Comments
Post a Comment