|
There are two things you could do. One is to
instantiate an object of type Ex6 in your app:
Ex6 ex = new Ex6();
...
int answer = ex.addint( table
);
or make addint a static method. The latter
would seem the most logical as the method does not reference instance
data. There is also a small modification (if I may suggest) that will make
it more robust -- it will handle empty arrays:
public static int addint( int [] array)
{
int sum = 0;
for (int p = 0; p <
array.length; p++) {
sum +=
array[p];
}
return sum;
}
In this case, of course, you would leave the
calling statement as is: int answer = Ex6.addint( table );
Tomm
--
Be careful when reading health books. You
might die of a misprint. - Mark Twain --- You are currently subscribed to jdjlist as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] |
