Reputation:
Actually i was going through some android source code and found these
public static class ToggleService extends IntentService {
super(ToggleService.class.getname());
I am not able to understand the use of super and also its parameters.
Upvotes: 0
Views: 393
Reputation: 200
Because ToggleService extends IntentService, by calling super from ToggleService, it is effectively calling IntentService's constructor, which is
/**
* Creates an IntentService. Invoked by your subclass's constructor.
*
* @param name Used to name the worker thread, important only for debugging.
*/
public IntentService(String name) {
super();
mName = name;
}
ToggleService.class.getname() will return the name of the ToggleService class, which in this case is a concatenated string constructing the package name of ToggleService and "ToggleService".
For more info: https://docs.oracle.com/javase/tutorial/java/IandI/super.html
Upvotes: 1
Reputation: 3263
If you have at look at the documentation
you will find that IntentService (base class of ToggleService) has a constructor which takes a string for debugging purposes. Super calls the constructor of the base class. So ToggleService just supplies its own name for debug logs to be prefixed with it.
Upvotes: 1
Reputation: 1360
super
is a keyword in Java
. It refers to the immediate parents property.
super() //refers parent's constructor
super.getMusic(); //refers to the parent's method
Upvotes: 0