Examples of the String
131-5923-213
1421-41-4-12-4
1-1
How would I extract the integers into an Array or find the sum of these integers? My code so far goes
int hyphenCount = socialNum.length()-socialNum.replaceAll("-", "").length();
ArrayList<Integer> sum = new ArrayList<Integer>();
for(int i = 0; i < hyphenCount; i++)
{
//my brain is too small
}
What I want to do is make a function like the following
public void extractSum(String s)
{
int outputSum;
//stuff
return outputSum;
}