To add to what Bill says, even if you declaration was correct:
public int abc(int def)
{
...
}
You need to return a value.
There are two types of method: void methods which return no value at all, and methods with a return type.
The former are simple to deal with: you can optionally use a
return
statement at any point in the method body at which point execution of the method will end and control will pass back to the instruction after the method was called. If you don't, then this will happen when execution of the method reaches the close curly bracket which ends the body definition.
But when you specify a return type then you must provide a
return
value for every possible path through the method: if there is a single path the compiler can see (even if the logic means it can't happen) your code will not compile.
Normally, that means putting a
return
statement at the end of the method immediately above the closing curly bracket for the method body.
That
return
statement must have a value which is compatible with the return type you specified when you declared the method.
So this will work:
public int abc(int def)
{
...
return 666;
}
But this won't:
public int abc(int def)
{
...
return "Hello world!";
}
Because an integer and a string are not compatible.
public int abc(int def)
{
if (def > 666)
{
return 666;
}
}
Will not work either, because there is a path where a return is not encountered.