In java you cannot pass functions as parameters to other functions. But objects.
Had it been java accepts functions as arguments it would have been like this:
button.setOnClickListener(playMusic); // where playMusic is a function
But in java's architecture, that's not accepted in this present day, so you pass in an object instead, which is an OnClickListener object.
So the code you wrote above is the same as;
View.OnClickListener playMusic = new View.OnClickListener() {
@Override
public void onClick(View view) {
media.startPlaying();
}
}
// and then pass playMusic to button onclick
button.setOnClickListener(playMusic); // where playMusic is now an object