Jump to content

Curly bracket programming language

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by TakuyaMurata (talk | contribs) at 15:18, 28 March 2004 (new article and vfd'd). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

{{subst:#ifeq:a|b||{{subst:#ifexist:Wikipedia:Articles for deletion/{{subst:PAGENAME}}|{{subst:lessthan}}!-- The nomination page for this article already existed when this tag was added. If this was because the article had been nominated for deletion before, and you wish to renominate it, please replace "page={{subst:PAGENAME}}" with "page={{subst:PAGENAME}} (2nd nomination)" below before proceeding with the nomination. -->}}}}This template must be substituted. Replace {{afd with {{subst:afd.

{{subst:lessthan}}!-- Once discussion is closed, please place on talk page:

-->


This is a brief overview of the syntax of Java.

Control structures

Loops

while (Boolean expression) {
    statement(s)
}


do {
    statement(s)
} while (Boolean expression);


for (initialisation ; termination condition ; incrementing expr) {
    statement(s)
}


Conditional statements

if (Boolean expression) {
    statement(s)
}


if (Boolean expression) {
    statement(s)
} else {
    statement(s)
}


With else if arbitrarily complex if-then-constructions may be built.

if (Boolean expression) {
    statement(s)
} else if (Boolean expression) {
    statement(s)
} else if (Boolean expression) {
    statement(s)
} else {
    statement(s)
}


switch (integer expression) {
    case constant integer expr:
         statement(s)
         break;
    ...
    default:
         statement(s)
         break;
}


Exception handling

try {
    statement(s)
} catch (exception type) {
    statement(s)
} catch (exception type) {
    statement(s)
} finally {
    statement(s)
}