java - How to inherit a RuntimeException class? -


i have 2 options:

public class syntaxexception extends runtimeexception {   private string msg;   public syntaxexception(string m) {     this.msg = m;   }   public string getmessage() {     return "invalid syntax: " + this.msg;   } } 

and

public class syntaxexception extends runtimeexception {   public syntaxexception(string m) {     super("invalid syntax: " + m);   } } 

which 1 preferred, if have think code maintainability , extendability?

use second one. argument constructor of both runtimeexception , inherited class error message, there's no reason duplicate functionality given runtimeexception in code.


Comments

Popular posts from this blog

SAP Web Service from .NET via WCF -

Optimized Line drawing in QT -

datetime - str to time in python -