How to convert the string to methods(like .Sendkeys) in Java? : Need to convert variable contains String to method call.

Example:
	
Variable:
	//Enter the name and value of the locator
	public String[] LoginID_Button = {"name","Log in"};

In my another class:

exact code:
        driver.findElement(By.**name**(loc1.LoginID_Button[1])).isDisplayed();

But I need to write as:
 driver.findElement(By.**loc1.LoginID_Button[0]**(loc1.LoginID_Button[1])).isDisplayed();

The name is in variable string but should be changed as Method. How to use it? Please help.