java - cannot find symbol when defining my own exception -


can tell me why getting "cannot find symbol" while compiling.

this how define own exception:

public void setidnumber(int i)throws invalidemployeeid   {   idnumber = i;     if ((idnumber <= 0))      {         throw new invalidemployeeid("invalid id. please input numeric id");      }    } 

cannot find symbol:

public void setidnumber(int i)throws invalidemployeeid

symbol: class invalidemployeeid

here try , catch statement in demo program:

 try     {      id = integer.parseint(input);      worker.setidnumber(id);    } catch (invalidemployeeid e)    {      system.out.println(e.getmessage());    } 

thanks in advance;

add class code:

public class invalidemployeeid extends exception {  public invalidemployeeid(string string) {     super(string); }  } 

just saying new not define exception you. furthermore, must consistent in usage of class names.

try   {  id = integer.parseint(input);  worker.setidnumber(id);  } catch (invalidemployeeid e) //must capital i!  {  system.out.println(e.getmessage());  } 

if already defined ivalidemployeeid exception subclass, must change line:

 throw new invalidemployeeid("invalid id. please input numeric id");  

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -