Forum Stats

  • 3,839,782 Users
  • 2,262,536 Discussions


BiFunction reference from a string representing classpath of the function (method)

Stan Hughes
Stan Hughes Member Posts: 21 Blue Ribbon

I am trying to figure out how I can use a string containing the classpath of a method to create a Bifunction reference I can use in a lambda. I may be going about this all wrong - but...

For instance:

If I had the following class:

package com;

public class Greeter {

  public String helloWorld(String firstname,String lastName) {

      return "Hello, "+firstname+" "+lastname;



How could I create a Bifunction reference from a string so that I could put it into a hashtable:

Hashtable<String,BiFunction<String,String,String>> functions = new Hashtable<>();

ReferenceToBiFunction ref = GetReferenceToBiFunctionFromString("com.Greeter::helloWorld");


Is there a way to do this?