title: Unable to pass in getter from class as argument using method
body: <p>I'm trying to do like a duplicate check for my application.</p>
  
  <p>For example, the user wants to change his username and hence, i got a getter function that basically gets the username from my class and compare to the user input via a duplicate function check. </p>
  
  <p>However, i have up to 10 fields that require such checking and the long way is to create 10 different duplicate function check for 10 different field which makes my code very long and messy.</p>
  
  <p>Hence, i used this <code>method</code> library to pass in the method into the function instead of creating multiple function.</p>
  
  <p>Here's how i attempted to use the library</p>
  
  <pre><code>//place where i read input and display any necessary info.
  import java.lang.reflect.Method;
  
  public void editUser()
  {
      Method method;
      boolean found = false;
      String userName = Keyboard.readString("Input username to change : ");
  
      for(User u : userData)
      {
          method = u.getuserName(); // error occur here, cannot convert string to method
          found = checkExist(userData, userName, method);
          if(!found)
          {
              System.out.println("does not exist");   
          }
  
          //do whatever stuffs if exist
  
      }
  }
  
  //function that check for existance.
  public void boolean checkExist(ArrayList&lt;User&gt; userData, String userName, Method method)
  {
      boolean found = false;
  
      for(User u : userData)
      {                       
          if(userName.equals(method))
          {
              found=true;
              break;
          }           
          else 
              found=false;            
      }   
      return found;
  }
  </code></pre>
  
  <p>When i attempt to initialize method variable with my getter method from my class which i declared it as a string, it says, <code>cannot convert string to method</code> </p>
  
  <p>Hence, what is the way where i can pass in my getter function from my other class without changing string to method as other function also reliable on this getter method.</p>
  
  <p>here's the constructor and the getter method</p>
  
  <pre><code>public Player(String userName)
  {
      this.userName=userName; 
  }
  
  public String getuserName() 
  {
      return userName;
  }
  </code></pre>