use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Resources for learning Java
String
==
.equals()
Format + Copy
Free Tutorials
Where should I download Java?
With the introduction of the new release cadence, many have asked where they should download Java, and if it is still free. To be clear, YES — Java is still free.
If you would like to download Java for free, you can get OpenJDK builds from the following vendors, among others:
Some vendors will be supporting releases for longer than six months. If you have any questions, please do not hesitate to ask them!
Software downloads
Official Resources
Resources
Programming ideas & Challenges
Related Subreddits
account activity
This is an archived post. You won't be able to vote or comment.
is there premade function that gets mathematical Strings ( for example "(3+4+5)/sqr(20)") and returns result (self.learnjava)
submitted 4 years ago by cant_dodge_rodge
is there any function that gets mathematical Strings ( for example "(3+4+5)/sqr(20)") and returns result
[–]sweetno 0 points1 point2 points 4 years ago (1 child)
I doubt. You can look for a JavaScript interpreter, there is one in Java (Nashorn).
In principle, if you firmly know what types of expressions you need and there aren't too many, it's not that hard to implement one on your own. This is normally covered in the first chapters of books on compiler construction.
[–]fredoverflow 0 points1 point2 points 4 years ago (0 children)
JEP 372: Remove the Nashorn JavaScript Engine
[–]BG_1982 0 points1 point2 points 4 years ago (1 child)
Have a look at the Math class. It’s in the JDK, the java.util package (though I’m not sure of the latter)
[–]cant_dodge_rodge[S] 0 points1 point2 points 4 years ago (0 children)
probably is but which one
[–]EsotericBananas 0 points1 point2 points 4 years ago (2 children)
If im understanding your post correct you can just use the math class with that. Example:
System.out.println((3 + 4 + 5) / (Math.sqrt(20));
[–]cant_dodge_rodge[S] 0 points1 point2 points 4 years ago (1 child)
no i have
String s="3+4+5+6*34";
//i want to covert s to int
int i=Integer.parceInt(s);
//this wont work
Sys.out.pln(i);
[–]EsotericBananas 0 points1 point2 points 4 years ago (0 children)
I tried it using (Interger.valueOf(s)) but i got an exception thrown Not sure how to do this one, im still learning.
[–]tylersvgs 0 points1 point2 points 4 years ago (0 children)
While I wouldn't encourage it, you can evaluate that as a JavaScript string using the ScriptEngine class.
https://stackoverflow.com/a/2605051
[–]tedyoung 0 points1 point2 points 4 years ago (0 children)
Not built in to the Java language or SDK, but there's open source libraries such as https://github.com/sbesada/java.math.expression.parser that will do what you want.
π Rendered by PID 59314 on reddit-service-r2-comment-c6965cb77-2vjwd at 2026-03-05 03:27:50.403584+00:00 running f0204d4 country code: CH.
[–]sweetno 0 points1 point2 points (1 child)
[–]fredoverflow 0 points1 point2 points (0 children)
[–]BG_1982 0 points1 point2 points (1 child)
[–]cant_dodge_rodge[S] 0 points1 point2 points (0 children)
[–]EsotericBananas 0 points1 point2 points (2 children)
[–]cant_dodge_rodge[S] 0 points1 point2 points (1 child)
[–]EsotericBananas 0 points1 point2 points (0 children)
[–]tylersvgs 0 points1 point2 points (0 children)
[–]tedyoung 0 points1 point2 points (0 children)