You need to sign in to do that
Don't have an account?
Non-void method might not return a value or might have statement after a return statement.
Hi am very new to apex am writing small program "fetch the account name from the account records by passing phone numer" am geting this erroe
Non-void method might not return a value or might have statement after a return statement. at line 7 column 1
my program
public class Fetch_Account_Name_From_Phone
{
public set<string>Fetch_Acc_Name(String p){
set<String> s1=new set<String>();
List<Account> acc=[select name from Account ];
for(Account a:acc)
{
String s=a.name;
s1.add(s);
System.debug('0019000000Btg2c'+s1);
return s1;
}
}
}
please can any one tel me how can i solve this problem
try this,
public class Fetch_Account_Name_From_Phone
{
public set<string>Fetch_Acc_Name(String p){
set<String> s1=new set<String>();
List<Account> acc=[select name from Account ];
for(Account a:acc)
{
String s=a.name;
s1.add(s);
System.debug('0019000000Btg2c'+s1);
}
return s1; // put this outside your for(Account a:acc) loop
}
}