Fandom

Programmer's Wiki

Throw an exception

407pages on
this wiki
Add New Page
Talk0 Share
16px-Pencil
Exceptions allow you to send a warning message to any programs that may be using your class. This allows the program to catch the Exception and deal with the problem.

Java Edit

public void riskyTask() throws Exception{
	if(somethingBad == true) {
		Throw new Exception();
	}
}

the throws Exception warns anyone using this method to deal with the exception it might throw.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.