Java Setting a placeholder or variable method

I know that something like this is possible in Python and other languages, but I’m looking to see if there’s something basic I’m overlooking in Java, or if the language just isn’t set up to do this Basically I want to have an if/then or switch which is presently like the following:

if X {
fillRect(<bunch of variables>);
} else
drawRect(<bunch of variables>);

and instead I want to do the following, which would be possible in other languages, and imho is more elegant because shouldn’t need to be repeated for a simple choice

if X{
funct = fillRect;
} else funct=drawRect;
funct(<bunch of variables>);

is there no reasonably easy way to do this?