You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
390 B

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