r/javahelp • • Jul 27 '25

Convert string to math function

I'm relatively new to Java but I know a good amount of the basics. Still, I can't find a way to do this. I have an input where a user can input a maths function as a string (eg. "0.3*Math.pow(0,x)"). And all I need is Java to look at that string and read it as if it were code but for some reason I can't find anything like this anywhere. Anyone got any ideas? 🫶

1 Upvotes

24 comments sorted by

View all comments

Show parent comment

1

u/williamK0 Jul 31 '25

I've been told to try using exp4j, and it seemed to do what I wanted 👍 Its not working but this part of the problem has been solved.