I would like to print a number in the main()
method which is the result returned from method foo()
. What should I do? Am I missing something?
I'm just exercising programming by making different pseudo-codes into an actual thing or well, functional...
This is the whole program, that I'm working on:
public class programB {
/* PSEUDO CODE:
*
* foo(A)
n ← A.length
x ← A[1]
for i ← 2 to n do
if A[i] > x then
x = A[i]
return x
*/
int array [] = {3,4,1,2,5};
static int foo(int[] array){
int n = 5;
int x = array[1];
for(int i = 2; i <= n; i++){
if(array[i] > x){
x = array[i];
}
}
return x;
}
public static void main(String[] arguments){
foo();
}
}
This is the error, that I'm getting:
Error: The method foo(int[]) in the type programB is not applicable for the arguments ()
Something about the method's arguments not being applicable...
Can someone please help me out here?