You need to sign in to do that
Don't have an account?
Sohail Barat 14
Non-void method might not return a value or might have statement after a return statement.
I am getting this error in my code:
Non-void method might not return a value or might have statement after a return statement.
My code is as under:
public class AccountHandler {
public static Account insertNewAccount(String AcctName)
{
Account acct = new Account();
acct.Name = AcctName;
if(acct.Name == null)
{
return null;
}
else
{
return acct;
}
}
}
Non-void method might not return a value or might have statement after a return statement.
My code is as under:
public class AccountHandler {
public static Account insertNewAccount(String AcctName)
{
Account acct = new Account();
acct.Name = AcctName;
if(acct.Name == null)
{
return null;
}
else
{
return acct;
}
}
}
Make sure you have return statement outside if else as well.
Thanks,
N.J
I can duplicate your error by commenting out either of the return lines. I'd double check your code, likely something missing in translation from what you have to what you've posted here.