0% found this document useful (0 votes)
20 views1 page

Exemples de code Java simples

The document provides examples of Java programming, including a simple 'Hello World' program, an addition operation, a for loop, a method to calculate the square of a number, and an example of iterating through an array. Each example demonstrates fundamental concepts in Java. These snippets serve as basic illustrations for beginners learning the language.

Uploaded by

rasoamiara1990
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Exemples de code Java simples

The document provides examples of Java programming, including a simple 'Hello World' program, an addition operation, a for loop, a method to calculate the square of a number, and an example of iterating through an array. Each example demonstrates fundamental concepts in Java. These snippets serve as basic illustrations for beginners learning the language.

Uploaded by

rasoamiara1990
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Exemples de programmation en Java

1. Hello World
public class HelloWorld {
public static void main(String[] args) {
[Link]("Hello, World!");
}
}

2. Addition
int a = 10, b = 20;
[Link]("Somme: " + (a + b));

3. Boucle for
for (int i = 0; i < 5; i++) {
[Link]("i = " + i);
}

4. Méthode
public static int carre(int x) {
return x * x;
}

5. Tableau
int[] nombres = {1, 2, 3};
for (int n : nombres) {
[Link](n);
}

You might also like