Stopping the main function?
<p>I'm very new to Java so please forgive me the noobish question in advance. I'd like to ask, though, if there is some instruction which ceases the rest of the main method? I mean: I have a public static void main and I have a special case of the algorithm which doesn't need most of the code to calculate as I know the output right from the start. So I'd like something like this:</p>

<pre><code>if(x==5) {System.out.print("sth"); return 0;}
</code></pre>

<p>But of course I can't return 0 as main is of void type. Is there some instruction to do so? I know that I could very well change the main to int or throw this exception and the rest of the calculations in a simple if-else, but maybe there's some better solution to this?</p>
