
Java / Statements
Java instructions are fundamental elements that define the actions to be executed by the Java Virtual Machine (JVM). Here is a summary of the main types of Java instructions:
Simple instruction : Ends with a semicolon ;.
Compound instruction (block) : Allows you to group several instructions. It is delimited by curly braces { }.
Variable visibility : Variables declared in a block are visible only in that block and nested blocks.
Syntax :variable = expression;
Example :int x = 5;
Instructionif : Allows a block of code to be executed if a condition is true. java if (condition) { // instructions à exécuter }
Instructionif...else : Allows execution of a block of code if the condition is true, otherwise another block. java if (condition) { // instructions si vrai } else { // instructions si faux }
Loopfor : Allows you to repeat a block of code a specified number of times. java for (initialisation; condition; incrémentation) { // instructions à répéter }
Loopwhile : Allows you to repeat a block of code as long as a condition is true. java while (condition) { // instructions à répéter }
break: Allows you to immediately exit a loop or a switch.
continue: Allows you to move to the next iteration of a loop.
Exception handling : Allows you to manage errors by capturing exceptions. java try { // code susceptible de générer une exception } catch (ExceptionType e) { // gestion de l'exception }
Instructionswitch : Evaluates a variable and executes the code block corresponding to the value of the variable. java switch (variable) { case valeur1: // instructions break; case valeur2: // instructions break; default: // instructions par défaut }
Variable declarations : int a;,String monNom;
Return instructions :return x;
Increment instruction :y++;
These instructions allow you to structure and control the execution flow of a Java program.
Log in to consult the resources on this page...
Not registered yet?
You need to practice more, masterize the fundamentals ? We offer you free resources and tech. watch.
However, unlike many resource sites that practice automatic registration, we take the time to get to know the users who register with Fond of Code, in accordance with the code of conduct available at www.theethicalweb.com...
You just have to fill out our form by clicking on the button below.... Thank you !

Reproduce this code, choosing one of the compilers below (don't copy and paste! It would be too easy). They all have the same function, just choose one according to your preferences.
When copying your code, replace the existing (default) code already in the compiler with your own.
Warning! For some of these compilers, you must choose the programming language yourself from the menu that is then offered. Of course, don't forget to click on RUN!
Some of the external links presented below, are not under the direct responsibility of Fond of Code. We cannot therefore be held responsible for the quality/Viability, or the temporary nor permanent interruption of some of them.
» Creation date: 1995
* Created by James Gosling and Patrick Naughton
* Developed by Oracle Corporation
* Influenced by Objective C, Pascal...
* Multi-platform
The comments you leave us are systematically subject to rigorous moderation. Incivility and slander, threats, intimidation of all kinds, more generally all gratuitous verbal violence, or the dissemination of unverified information... are not tolerated. We also reserve the right to publish only comments which effectively advance the debate and allow a better understanding of the subject covered by the article presented on this page (as well as all its ramifications) and this, whatever its overall content.
Fond of Code TM © ®
All rights reserved - Protected Trademark/Logo (INPI)
Legal structures based in
Nice - FRANCE
Montreal - Canada
By appointment
SIRET: 41138921600028 (France)
Inc. : 661515-5 (Canada, Qc.)
Official resumption in France : March 2025
Beta version of the website : May 2024
Implementation : July 2024
Launch of initial activity : 1996 (Europe and North America)
New version of the website : April 2025
Fond of Code official launch : May 2025