Skip to content

Lidt sjov med Java

Vi kender det alle - man bruger en finally fordi man er sikker på at den altid vil blive kørt... Men er vi nu også helt sikker på det? Nææh, men ideen er da god:
try {
    if (choice) {
        while (true) ;
    } else {
        System.exit(1);
    }
} finally {
    code.to.cleanup();
}

Bare fordi det står i bøgerne skal man ikke altid tro på det.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

The author does not allow comments to this entry

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Form options