You need to sign in to do that
Don't have an account?
chanti k
i am getting the below error 's in apex class
Hi,
i am new to apex class , i am getting below errors as well as i put the comments with errors.
kindly help me on this. i appricated!
i am new to apex class , i am getting below errors as well as i put the comments with errors.
Public class fetchdisplayrecords { public Contact Con{get; set;} public string selectedItemValue{get;set;} public id resc{get;set;} public fetchdisplayrecords(ApexPages.StandardController controller) { //acc = [SELECT Name, AccountNumber FROM Account limit 5]; } public List<selectoption> getitems() { List<Selectoption> opts = new List<Selectoption>(); opts.add(new selectoption('','--None--')); // Compile Error: Non-void method might not return a value or might have statement after a return statement. } }
kindly help me on this. i appricated!
In getitems() method return type is List<selectoption> then you should return LIst<selectoption> you are not retuning anything thats way it is showing error. try this bellow code
If you don't want to return anything put void as return type that means you have to write the getitems() in following way
If you have any queries on this feel free to ask me.
Thank you
add below statement after line number 13
return opts;
becoz it is non void method you should return somthing and return type of your method is List<Selectoption>,thats why you should return list.
if your problem has solved please make it as solved and best answer so that we can try to help others