I'm a beginner to java and programming.
I have a string s="(((1+2))-((5+6))-((10+20))-((6-18))+((9+10)))"
I would like to put it into a list or array.
Something like this,
[(, (, (, 1, +, 2, ), ), -, (, (, 5, +, 6, ), ), -, (, (, 10, +, 20, ), ), -, (, (, 6, -, 18, ), ), _, (, (, 9, +, 10, ), ), )]
Upon executing
char[] a = String.valueOf("(((1+2))-((5+6))-((10+20))-((6-18))+((9+10)))").toCharArray();
result is
[(, (, (, 1, +, 2, ), ), -, (, (, 5, +, 6, ), ), -, (, (, 1, 0, +, 2, 0, ), ), -, (, (, 6, -, 1, 8, ), ), +, (, (, 9, +, 1, 0, ), ), )]
please note that 10 is coming as 1 and 0
EDIT:
I would like to put it into a list of string
Something like this,
List<String> ls = [(, (, (, 1, +, 2, ), ), -, (, (, 5, +, 6, ), ), -, (, (, 10, +, 20, ), ), -, (, (, 6, -, 18, ), ), _, (, (, 9, +, 10, ), ), )]
Could somebody tell me how I can do it?
s.toCharArray().10is not a char. If you trychar ss = '10', you get compile error.