Calling secondary method/function
Right this is a really novice question i thi开发者_运维百科nk.. but I've not got any idea what its called...
I've got a class called Tasks. I wanna be able to call Tasks.Preferences.getString();
Do i need to make another class within Tasks called Preferences then make a function within that called getString?
Well that's what i tried but apparently Tasks.Preferences doesn't exist, so i cant get to the inner function, all of these classes are public btw.
Any help would be much appreciated, Thank you.
Preferences shouldn't be another class, it should be a member of tasks. i.e.:
public class Tasks {
public Prefs Preferences;
}
public class Prefs {
public String getString() {
//do something
}
}
It depends on what you need. You can just use method getPreferences() of your Task class and then call getString(). If Preferences are created and used only with Task then you can do it inner class of Task.
精彩评论