0

I want to make a program where the user can enter "sin(x)" and the computer will treat it as "Math.sin(x)". Is there some way I can do this? ps. I tried import static java.lang.Math.*; and it doesn't work.

connor
  • 1
  • 2
    Please provide example code - it looks like you need dynamic code evaluation; which Java does not support as it is a compiled language. – Boris the Spider Jan 08 '17 at 18:59
  • maybe define a function `double sin(double x) {return Math.sin(x)};` – Cherubim Jan 08 '17 at 19:01
  • And figure out if your problem is evaluating user input (as in the duplicate, and "for user input" implies), or evaluating `sin(x)` in that user input (which the rest of your question suggests). – Teepeemm Jan 08 '17 at 20:08

0 Answers0