Ошибка в том, что findTarget
является функцией класса.
Итак, где у вас это:
test ob = new test();
String testing = findTarget(target1, source1);
... должно быть изменено для вызова функции из статического контекста:
//test ob = new test(); not needed, the function is static
int testing = test.findTarget(target1, source1);
// also changed the testing type from String to int, as int IS findTarget's return type.
У меня нет содержимого файла для пробного запуска, но это, по крайней мере, должно помочь устранить ошибку.
=====
UPDATE:
Вы близко!
Внутри main измените код в вашем цикле так, чтобы он выглядел так:
String target1;
int testing = 0; // move and initialize testing here
while ((target1 = br.readLine()) != null) //as long the condition is not null it will keep printing.
{
//System.out.println(target1);
testing += test.findTarget(target1, source1);
//target1 = br.readLine();
}
System.out.println("answer is: "+testing);