How to can make operator numbers in string as int in kotlinHow can I permanently enable line numbers in IntelliJ?How do I iterate over the words of a string?How do I read / convert an InputStream into a String in Java?How would you count occurrences of a string (actually a char) within a string?Convert bytes to a string?How do I make the first letter of a string uppercase in JavaScript?How to replace all occurrences of a string?How to check whether a string contains a substring in JavaScript?How do I convert a String to an int in Java?Easiest way to convert int to string in C++
Why didn't Doc believe Marty was from the future?
What is Soda Fountain Etiquette?
To what extent should we fear giving offense?
Should I ask for a raise one month before the end of an internship?
Is the internet in Madagascar faster than in UK?
Find feasible point in polynomial time in linear programming
Why did Lucius make a deal out of Buckbeak hurting Draco but not about Draco being turned into a ferret?
Spicing up a moment of peace
Should I use the words "pyromancy" and "necromancy" even if they don't mean what people think they do?
accurate measurement from inaccurate tools
Did ancient peoples ever hide their treasure behind puzzles?
Can a network vulnerability be exploited locally?
Does the Tribal card type have inherent mechanical implications?
Why does と思います point to "you"?
How to say "I only speak one language which is English" in French?
Did the Apollo Guidance Computer really use 60% of the world's ICs in 1963?
Could the UK amend the European Withdrawal Act and revoke the Article 50 invocation?
Why does the weaker C–H bond have a higher wavenumber than the C=O bond?
Was the six engine Boeing-747 ever thought about?
Would it be better to write a trilogy over a much longer series?
Are there any to-scale diagrams of the TRAPPIST-1 system?
How does attacking during a conversation affect initiative?
Is the Amazon rainforest the "world's lungs"?
Journal published a paper without my permission when I had serious objection about the content
How to can make operator numbers in string as int in kotlin
How can I permanently enable line numbers in IntelliJ?How do I iterate over the words of a string?How do I read / convert an InputStream into a String in Java?How would you count occurrences of a string (actually a char) within a string?Convert bytes to a string?How do I make the first letter of a string uppercase in JavaScript?How to replace all occurrences of a string?How to check whether a string contains a substring in JavaScript?How do I convert a String to an int in Java?Easiest way to convert int to string in C++
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to create operator in string and show the value as int.
// ex:
val str= "1+2*3" , print out -> "1+2*3"
// i want:
print out -> 7
however i tried to create kotlin code like:
val str= "$1+2*3" or val str= "1+2*3".toInt
but all this don't work.
any help???
java string intellij-idea kotlin int
add a comment |
I want to create operator in string and show the value as int.
// ex:
val str= "1+2*3" , print out -> "1+2*3"
// i want:
print out -> 7
however i tried to create kotlin code like:
val str= "$1+2*3" or val str= "1+2*3".toInt
but all this don't work.
any help???
java string intellij-idea kotlin int
1
You're going to need some kind of a parser here. Btw, it's 7, not 9.
– Pavel Smirnov
Mar 27 at 21:21
add a comment |
I want to create operator in string and show the value as int.
// ex:
val str= "1+2*3" , print out -> "1+2*3"
// i want:
print out -> 7
however i tried to create kotlin code like:
val str= "$1+2*3" or val str= "1+2*3".toInt
but all this don't work.
any help???
java string intellij-idea kotlin int
I want to create operator in string and show the value as int.
// ex:
val str= "1+2*3" , print out -> "1+2*3"
// i want:
print out -> 7
however i tried to create kotlin code like:
val str= "$1+2*3" or val str= "1+2*3".toInt
but all this don't work.
any help???
java string intellij-idea kotlin int
java string intellij-idea kotlin int
edited Apr 5 at 11:04
Martijn Pieters♦
756k163 gold badges2751 silver badges2468 bronze badges
756k163 gold badges2751 silver badges2468 bronze badges
asked Mar 27 at 21:18
Youn TivoliYoun Tivoli
121 silver badge10 bronze badges
121 silver badge10 bronze badges
1
You're going to need some kind of a parser here. Btw, it's 7, not 9.
– Pavel Smirnov
Mar 27 at 21:21
add a comment |
1
You're going to need some kind of a parser here. Btw, it's 7, not 9.
– Pavel Smirnov
Mar 27 at 21:21
1
1
You're going to need some kind of a parser here. Btw, it's 7, not 9.
– Pavel Smirnov
Mar 27 at 21:21
You're going to need some kind of a parser here. Btw, it's 7, not 9.
– Pavel Smirnov
Mar 27 at 21:21
add a comment |
1 Answer
1
active
oldest
votes
You need to have some kind of parsers to achieve that.
Few examples
http://mathparser.org/
The advantage with the above is that you can perform any kind of calculation like below.
Expression e = new Expression("( 2 + 3/4 + sin(pi) )/2");
double v = e.calculate()
Or by using the Java inbuilt Scriptengine.
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
String foo = "1+2*3";
System.out.println(engine.eval(foo)); //prints 7
Thank you so much sir ,it's work for me.
– Youn Tivoli
Mar 28 at 7:17
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386611%2fhow-to-can-make-operator-numbers-in-string-as-int-in-kotlin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to have some kind of parsers to achieve that.
Few examples
http://mathparser.org/
The advantage with the above is that you can perform any kind of calculation like below.
Expression e = new Expression("( 2 + 3/4 + sin(pi) )/2");
double v = e.calculate()
Or by using the Java inbuilt Scriptengine.
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
String foo = "1+2*3";
System.out.println(engine.eval(foo)); //prints 7
Thank you so much sir ,it's work for me.
– Youn Tivoli
Mar 28 at 7:17
add a comment |
You need to have some kind of parsers to achieve that.
Few examples
http://mathparser.org/
The advantage with the above is that you can perform any kind of calculation like below.
Expression e = new Expression("( 2 + 3/4 + sin(pi) )/2");
double v = e.calculate()
Or by using the Java inbuilt Scriptengine.
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
String foo = "1+2*3";
System.out.println(engine.eval(foo)); //prints 7
Thank you so much sir ,it's work for me.
– Youn Tivoli
Mar 28 at 7:17
add a comment |
You need to have some kind of parsers to achieve that.
Few examples
http://mathparser.org/
The advantage with the above is that you can perform any kind of calculation like below.
Expression e = new Expression("( 2 + 3/4 + sin(pi) )/2");
double v = e.calculate()
Or by using the Java inbuilt Scriptengine.
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
String foo = "1+2*3";
System.out.println(engine.eval(foo)); //prints 7
You need to have some kind of parsers to achieve that.
Few examples
http://mathparser.org/
The advantage with the above is that you can perform any kind of calculation like below.
Expression e = new Expression("( 2 + 3/4 + sin(pi) )/2");
double v = e.calculate()
Or by using the Java inbuilt Scriptengine.
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
String foo = "1+2*3";
System.out.println(engine.eval(foo)); //prints 7
answered Mar 27 at 21:50
JeyaprakashJeyaprakash
7022 gold badges6 silver badges24 bronze badges
7022 gold badges6 silver badges24 bronze badges
Thank you so much sir ,it's work for me.
– Youn Tivoli
Mar 28 at 7:17
add a comment |
Thank you so much sir ,it's work for me.
– Youn Tivoli
Mar 28 at 7:17
Thank you so much sir ,it's work for me.
– Youn Tivoli
Mar 28 at 7:17
Thank you so much sir ,it's work for me.
– Youn Tivoli
Mar 28 at 7:17
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386611%2fhow-to-can-make-operator-numbers-in-string-as-int-in-kotlin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You're going to need some kind of a parser here. Btw, it's 7, not 9.
– Pavel Smirnov
Mar 27 at 21:21