Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kolami committed Dec 27, 2023
0 parents commit b916ac4
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions initiation-java.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
57 changes: 57 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
public class Main {
public static void main(String[] args) {

// Le classique Hello World! qui apparait dans la console
System.out.println("Hello world!");

// Chaque instruction est terminée par un ;

// System.out.println permet d'afficher ce que l'on veut dans la console
System.out.println("Mes débuts en java");

// Les différents types de variable courant procédurale :
int nbreEntier = 5;
boolean vraiFaux = true;
String chaineCaractere = "On peut y glisser ce que l'on veut la dedans";

System.out.println(chaineCaractere.getClass()); // en ajoutant .getClass() derriere ta variable, tu peux afficher son type

float decimal = 2.21f; // bien ajouté le f pour spécifier un float

int[] tableauEntier = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // un tableau "classique" mais typé de int
String[] tableauChaineCaractere = {"Iron man", "Thor", "Ultron", "Deadpool"}; // un tableau "classique" mais typé de String

System.out.println("Le tableau d'entier : "+tableauEntier);
System.out.println("Combien d'éléments dans le tableau d'entier : "+tableauEntier.length);
System.out.println("Le tableau de String : "+tableauChaineCaractere);
System.out.println("Combien d'éléments dans le tableau de String : "+tableauChaineCaractere.length);

// Afficher un tableau complet, je n'ai pas l'impression que ce soit faisable mais on peut accéder aux différents en les appelant directement

System.out.println(tableauChaineCaractere[0]); // Le chiffre correspond à l'index du tableau qui commence toujours à 0
System.out.println(tableauChaineCaractere[1]);
System.out.println(tableauChaineCaractere[2]);
System.out.println(tableauChaineCaractere[3]);

// Ce qui nous amene aux boucles :
// 3 types de boucles en procédural : for, while et la do/while (moins utilisé)
System.out.println("Affichage de la boucle for en ligne");
for(int i=0; i<10; i++){ // int i = 0 => index d'incrément, i<10 => condition de sortie de la boucle, i++ => incrément de l'index de +1 (i++ équivaut à i=i+1)
System.out.print(i);
}

System.out.println("\nAffichage de la boucle while en ligne"); // \n retour a la ligne dans le print
int i =0;
while (i<10){
System.out.print(i);
i++;
}

System.out.println("\nAffichage de la boucle do/while en ligne");
int index = 0;
do {
System.out.print(index);
index++;
}while (index<10);
}
}

0 comments on commit b916ac4

Please sign in to comment.