public class EnumTest { Public enum Season {Spring,Summer,fall,winter} Public static Void SeasonFinder(Season CurrentSeason) { If(CurrentSeason == Season.Spring || CurrentSeason == Season.fall ) { System.debug('Neither cold nor hot'); } else if(CurrentSeason == Season.Summer) { System.debug('It is hot'); } Else if(CurrentSeason == Season.Winter) { System.debug('It is Cold'); } Else { System.debug('Invalid Season'); } } }
I need to call the function SeasonFinder. But how do I pass the parameter of type season? Am getting error like variable season does not exist.
You have to call it as static so the call would be like this:
seasonTest.SeasonFinder(EnumTest.Season.Summer)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.