-1
I’m doing an exercise where the program receives as input a "String" with two values , and in the end I need to put these two values into integer variables and carry out the sum of them. I researched and read about the Bufferreader and the Stringtokenizer. My question is how to implement this, I need to make a Bufferreader to read the String that will be inserted and the Stringtokenizer performs this separation of my string into two? And how I turn that string into integers?
Entrada: "11 8"
Saida : 19
Code I’ve made so far:
public class MinhaPrimeiraClasse {
 public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String valor = " ";
    
    System.out.println("Insira os valores:");
    valor = br.nextLine();
    Integer a = 0;
    Integer b = 0;
    Integer c = a + b;
    
    a = Integer.parseInt(br.readLine());
    b = Integer.parseInt(br.readLine());
    System.out.println(" "+c);
 }
}
I don’t know how to separate the string and play the two values in the variables a and b
In the specific case of
System.in, does not need (and would say not need) to close it: https://answall.com/a/380458/112052– hkotsubo
@hkotsubo. I did not know that, for me had to close in all cases.
– Augusto Vasques