I started learning Java yesterday and I am now trying to create a program that sums a list of integers in the form of strings. When I try to compile and run the program in Eclipse I get the following error. "The method doSomething(String[]) in the type Calculator is not applicable for the arguments (String, String)". Sorry for that my code looks all messed up. I didn't figure out how to make all of the code in a different font. I got the "inspiration" of trying to pass multiple arguments to a function from the main class since it seems to be working there. I have tried to instead write (String ... arguments) which seems to work fine.
public class Sum {
int doSomething(String[] arguments) {
int sum = 0;
for (int i = 0; i < arguments.length; i++) {
sum += Integer.parseInt(arguments[i]);
}
return sum;
}
public static void main(String[] args) {
String var = "1";
System.out.print(doSomething("531", var));
}
}