Java says I must return an Object, but I'm throwing exceptions -


So I'm trying to catch exceptions where I can not return a directory, but Java will not let me How do I configure the code so that Java can let me run it?

  Public directory path (string path) exception {throws {string [] arrayPath = path.split ("/"); Directory cwd_copy = FileSystem.getRoot (); Try {// Full Path if (path.startsWith ("/")} {for (int x = 1; x & lt; circope.long; x ++) {if (stuff) {} else {new exception ; }}} Return cwd_copy; } Hold (exception e) {pathErrorMsg (); }}    

No, you could be throw an exception , But then you grab it and do nothing with it! If you take the logical step with that code, you will see that there is no way to return to any directory and there is no exception to throw, because there are possible routes for the method of termination. It will not fly.

Instead,

  throws public directory path (string path) pathdoid expression {string [] arrayPath = path.split ("/"); Directory cwd_copy = FileSystem.getRoot (); // complete path if (path.startsWith ("/")} {{int x = 1; x & lt; arraypath; height} x ++} {if (stuff) {else else} new pathToDirException (/ * Some text goes here! * /); }}} Return cwd_copy; }   

Where Pathtoire Exception is a check exception class that you have created for this system / class problems.

Or if you have an attempt / hold block in the method, and then need to throw an exception, throw your new exception class, but the exception being the constructor parameter in its new exception Pass on.

Comments

Popular posts from this blog

php - how to change mysql_result($res, 0, "url"); to mysqli -

c# - Textbox not clickable but editable -

Matlab transpose a table vector -