-2

I am new in programming. I am sorry for question. I can not understand what does it mean. Piese of code

  public void onRadioButtonClicked(View view) {    
    boolean checked = ((RadioButton)view).isChecked();

What does this sintaxis of construction mean, how is named it to find and read.((RadioButton)view) Thank you.

Infff
  • 3
  • 2
  • It's casting the view to `RadioButton` so it can access a `RadioButton` method. – khelwood Jul 06 '20 at 10:58
  • This is Type-Casting i.e, We get a `View` on `onRadioButtonClicked` method as a parameter. We can't use the functions associated with `RadioButton` on `View` object. So, we _Type-Cast_ `View` to `RadioButton`. In simple terms, we are saying the IDE to consider `view` as a `RadioButton`. Hope this makes sense. Feel free to ask for clarifications... – Vishnu Jul 06 '20 at 11:04

1 Answers1

0

View class inherits from RadioButton class. This method - onRadioButtonClicked must for various reasons,accept an object of View kind. but for use there parent's method - .isChecked() method You have to look at him in the 'glasses' of parent class.

its use polymorephism ability. you can see more here

to-b
  • 118
  • 11