I have an input with the line breaks. I want to convert that string into an array, and for every new line, jump one index place in the array.
If the input is:
100
200
300
Then I need the output to be:
110
210
310
I have used the following code:
public class NewClass {
public static void main(String args[]) throws IOException {
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
String str=br.readLine();
String [] arrOfStr = str.split("\n");int b=0;
for (String a : arrOfStr) {
b=Integer.parseInt(a);
int c=b+10;
System.out.println(c);
}
}
}
But it is not giving the desired output. Note: We are not taking the input from text file. We don't know how many inputs are there in test case. We have take inputs in one go.