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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -