I have a Java string like "10 20 3 0"
, now I would like to convert it into an array list. I know that in C++, the code should be like this:
string s = "10 20 3 0";
stringstream ss(s);
vector<int> arr;
string tmp;
while (ss >> tmp)
{
arr.push_back(stoi(tmp));
}
How can I do this in Java, since I am quite new to java.