I have an alert message and I need to call this from different part of my code. Base on user interaction I will show this alert and pass some parameter based on this parameter my alert should behave for eg.
private void alert(String message, String title, Method methodReference) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setCancelable(false);
        builder.setPositiveButton("Yes", (DialogInterface.OnClickListener) (dialog, which) -> {
           methodReference();    // I want to replace methodReference with that method that will pass while calling alert
        });
        builder.setNegativeButton("No", (DialogInterface.OnClickListener) (dialog, which) -> {
            dialog.cancel();
        });
        AlertDialog alertDialog = builder.create();
        alertDialog.show();
    }
I want to replace methodReference with that method that will pass while calling alert
eg.
alert("message", "title", doWork()); 
or
alert("message", "title", workInProgress());  
 
    