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;








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???










share|improve this question





















  • 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

















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???










share|improve this question





















  • 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













0












0








0


1






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???










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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












  • 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












1 Answer
1






active

oldest

votes


















1















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





share|improve this answer

























  • Thank you so much sir ,it's work for me.

    – Youn Tivoli
    Mar 28 at 7:17











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
);



);













draft saved

draft discarded


















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









1















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





share|improve this answer

























  • Thank you so much sir ,it's work for me.

    – Youn Tivoli
    Mar 28 at 7:17
















1















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





share|improve this answer

























  • Thank you so much sir ,it's work for me.

    – Youn Tivoli
    Mar 28 at 7:17














1














1










1









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





share|improve this answer













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






share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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









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.



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해