I am working on my first Calculator project on GUI, I get the input and concate it in a String field by using Action Listner.
calculation = calculation + " 4 ";
calculation = calculation + " * ";
calculation = calculation + " 9 ";
Taking the first number and the second number by using substring, converting them and putting them in two fields
num1 = Integer.parseInt(calculation.substring(0, 1));
num2 = Integer.parseInt(calculation.substring(4, 5));
The problem is that I cannot use substring more than x digits before the operator and y digits after the operator. Can I do that by using subString built-in method? and If I can't, How can I do that by using any other methods?