What type of exception will the enum value of java throw?

492    Asked by AkanshaChawla in Salesforce , Asked on Feb 7, 2023

In Winter 22 we are getting a long desired (if somewhat niche) feature: Use the valueOf() Enum Method to Convert a Specified String to an Enum Constant Value

The valueOf() enum method converts a specified string to an enum constant value. An exception is thrown if the input string doesn’t match an enum value. In previous releases, using this method resulted in a runtime error.


What type of exception specifically is thrown?

Answered by Aashna Saito

The exception that the enum value of java throw is a System.NoSuchElementException in the prerelease edition of Winter '22, so that is likely what it will be in the release.


Your Answer

Interviews

Parent Categories