почему сложение считает не правильно?
package com.javarush.task.task19.task1914;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.Reader;
/*
Решаем пример
*/
public class Solution {
public static TestString testString = new TestString();
public static void main(String[] args) {
PrintStream console = System.out;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(byteArrayOutputStream);
System.setOut(stream);
testString.printSomething();
System.setOut(console);
String str = byteArrayOutputStream.toString();
str = str.substring(0, str.length()-2);
String[]strArr = str.split(" ");
switch (strArr[1]){
case "+":{
System.out.println(str + (Integer.parseInt(strArr[0])+Integer.parseInt(strArr[2])));
break;
}
case "-":{
System.out.println(str + (Integer.parseInt(strArr[0])-Integer.parseInt(strArr[2])));
break;
}
case "*":{
System.out.println(str + (Integer.parseInt(strArr[0])*Integer.parseInt(strArr[2])));
break;
}
}
}
public static class TestString {
public void printSomething() {
System.out.println("3 + 6 = ");
}
}
}