Originally Posted by
Norm
That is the String from a String array.
Have you tried printing the contents of these arrays: splitNumbers and splitSymbols
I think I've finally figured it out, but I'm not completely sure. I think I've got both the operands and operators in arrays, but as I've used different ways to get them in to the arrays I'm not sure if they're both actually in Arrays. Would it be OK if you had a quick look at the code for me?
public static void parseInput(String stringCalculator)
{
String[] operand= stringCalculator.split("([-+*/])");
String operator = stringCalculator.replaceAll("[0-9]", "");
System.out.println("Arraylist operands contains: " + Arrays.toString(operand));
ArrayList<String> calcOperators = new ArrayList<String>();
calcOperators.add(operator);
System.out.println("Arraylist operators contains: " + calcOperators.toString());
}
When the input of "1+2*3-4/5+6" is inputted the output is:
Arraylist operands contains: [1, 2, 3, 4, 5, 6]
Arraylist operators contains: [+*-/+]
Thanks for all the help!