Curly bracket programming language: Difference between revisions

Content deleted Content added
m Oops, correcting C++
Dexbot (talk | contribs)
m Bot: Fixing broken section link
Tag: Redirect target changed
 
(192 intermediate revisions by more than 100 users not shown)
Line 1:
#REDIRECT [[List of programming languages by type#Curly bracket languages]]
The syntax of the [[Java programming language]] derives heavily from [[C syntax|C]] and [[C Plus Plus|C++]] syntax. The control structures are identical, but Java adds keywords and syntactic features to ease certain [[Object oriented programming]] idioms.
 
{{Redirect category shell|1=
=== Control structures ===
{{R to section}}
 
}}
==== 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)''
}