java - How to split string if splitting character is dynamic or unknown? -
i want make java program in want take string input. string have 2 integer numbers , operation performed. eg. 25+85 or 15*78
the output solution of string.
but don't know how split string because operator sign not known before execution.
you want check operation using using string.contains("+"); , checking other operators want support. split wherever operator is, string.split("+"). there parse output of string.split("+") using integer.parseint(string s) , return sum. pretty simple, luck.
Comments
Post a Comment