I understood that if I need to call getItemList
ouside the class without an object, I need to make the method public and static. What I am confused about is the case inside the class.
In the following code, can I call getItemList
method without creating a GitHubClient
object? If I want to call getItemList
method directly, should I make the method static?
public class GitHubClient {
private String s1 = "abc"
public List<Item> search(double lat, double lon, String keyword) {
// omit code using GitHub client to request info
String responseBody = EntityUtils.toString(entity);
JSONArray array = new JSONArray(responseBody);
// can I call the method without an object
return getItemList(array);
}
private List<Item> getItemList(JSONArray array) {
// helper function to filter the search result
}
}