public class ParseString{ private String str; public ParseString(String str){ this.str = str; } public double sumOfAll(){ String[] parts = this.str.split(",| +"); double total = 0; for (int i = 0; i < parts.length; i ++){ total += Double.parseDouble(parts[i]); } return total; } }