что то не то с выводом
package com.javarush.task.task19.task1914;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
/*
Решаем пример
*/
public class Solution {
public static TestString testString = new TestString();
public static void main(String[] args) {
PrintStream olda = System.out;
ByteArrayOutputStream bytte = new ByteArrayOutputStream();
PrintStream newa = new PrintStream(bytte);
System.setOut(newa);
testString.printSomething();
System.setOut(olda);
String strin = bytte.toString();
String[] str = strin.split(" ");
String znak = str[1];
int first = Integer.parseInt(str[0]);
int second = Integer.parseInt(str[2]);
Integer ans = null;
if (znak.equals("+"))
ans = first + second;
else if (znak.equals("-"))
ans = first + second;
else if (znak.equals("*"))
ans = first + second;
System.out.println(first + " " + znak + " " + second + " = " + ans);
}
public static class TestString {
public void printSomething() {
System.out.println("3 + 6 = ");
}
}
}