How would I execute a function by a string, and get it's return value

So like let's say I have a string, and it's set to "login", how would I call the function login() from that string. Also it needs parameters.

The function I am using is:

boolean login(String username, String password) {
  Object[] usernames = users.keys().toArray();
  boolean success = false;
  for(Object i: usernames) {
    if(i.equals(username)) {
      JSONObject user = users.getJSONObject((String)i);
      if(password.equals(user.getString("password"))) {
        success = true;
      }
    }
  }
  return success;
} 

Answers

Sign In or Register to comment.