Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Calculating the numeric value of a string

807589Nov 11 2008 — edited Nov 11 2008
My goal is to retrieve the mathematical value of a String. E.g:
public class Calculator {
    
    public static void main(String args[]) {
        System.out.println(Calculator.calc("3 + 2"));
    }
    
    public static double calc(String calculation) {
        double result;
        //Calculate
        return result;
    }
}
Is there a class or a library that has this functionality? If so, where could I find this.

Thanks in advance

Vincent
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 9 2008
Added on Nov 11 2008
6 comments
260 views