SlideShare une entreprise Scribd logo
1  sur  207
Formation OCA Java Se 8 Programmer (1Z0-808)
Formation OCA, Java Se 8 Programmer 1Z0-808
Préparée par:
Anis HACHANI
Formateur et consultant en IT
Certifié OCJP, RHCE 6&7, LPI-3, OCE, OCA, OCP
Comptia Sec+, Agile ( PSM )
Formation OCA Java Se 8 Programmer (1Z0-808)
Présentation générale
Le programme de certification Java est offert par Oracle, actuellement la plupart des entreprises préfèrent embaucher des
personnes qui ont une certification.
Une certification Java prouve qu'une personne est compétent dans la technologie Java et possède les compétences
requises définit nécessaires pour effectuer une tâche spécifique
Avoir une certification permet d’ouvrir plusieurs opportunités à savoir :
Cursus du développeur mobile ( Android )
Cursus du développeur web ( JEE , Spring framework ..)
Cursus développeur Java Desktop Application
En plus == > Avoir la certification, ça implique la maitrise du concept de l’orienté objet
 Python, Php, Ruby, Objective C, Swift, …
Formation OCA Java Se 8 Programmer (1Z0-808)
Présentation générale
Formation OCA Java Se 8 Programmer I 1Z0-808
Formation OCA Java Se 8 Programmer (1Z0-808)
Présentation formateur
Anis Hachani
Contact : contact@ghazelatc.com
Mon profil LinkedIn : https://www.linkedin.com/in/anis-hachani-546bb13a/
Formateur ,Chef de projet et consultant en IT
Fondateur de Ghazela Technology Academy :
Formation et consulting en Technology, Management et en Digital
Sous-traitance de projets informatique
Je dispense des formations en IT depuis plus de 6 ans.
Formation OCA Java Se 8 Programmer (1Z0-808)
Plan formation
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..)
Java Building Blocks
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else)
Operators and Statments
Chapitre 3 : Librairie native de java, (API Java )
Core Java APIs
Chapitre 4 : Méthode et encapsulation
Methodes and Encapsultion
Chapitre 5 : Héritage, Polymorphisme , Interface, classes abstraites
Class Design
Chapitre 6 : Les Exceptions, les classe imbriquées, les classes
anonymes, Lambda
Exceptions, Inner class, Anonymous class, Lambda
Formation OCA Java Se 8 Programmer (1Z0-808)
Prérequis
Avoir suivi la formation Programmation Orientée Objet en Java ou avoir les
connaissances équivalentes
Avoir une bonne pratique du langage Java sur au moins un projet.
Formation OCA Java Se 8 Programmer (1Z0-808)
Public concerné
Développeur Java
Chef de projet
Développeur ayant codé avec un autre langage de programmation orienté
objet
Formation OCA Java Se 8 Programmer (1Z0-808)
Objectifs visés
Réussir la certification " Oracle Certified Associate, Java SE 8 Programmer I ,OCJA 8
, 1Z0-808
Formation OCA Java Se 8 Programmer (1Z0-808)
Environnement de travail
Machine : Windows XP/7/8/8.1/10.. | Linux ou Unix
Outils : Bloc note , note pad ++
IDE : Netbeans | Eclipse| autre IDE
Programme à télécharger : JDK 1.8
Formation OCA Java Se 8 Programmer (1Z0-808)
Liens des ressources logicielles
Note pad ++ : https://notepad-plus-plus.org/download/v7.3.3.html
Netbeans : https://netbeans.org/downloads/
JDK 1.8 : http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-
2133151.html
Lien dans le site officiel : https://education.oracle.com/pls/web_prod-plq-
dad/db_pages.getpage?page_id=5001&get_params=p_exam_id:1Z0-808
Formation OCA Java Se 8 Programmer (1Z0-808)
Aperçu sur l’examen OCJA – 1Z0-808
La langue de l’examen
est aux choix :
Français, Anglais …
Lien dans le site officiel :
https://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=5001&get_params=p_exam_id:1Z0-808
Formation OCA Java Se 8 Programmer (1Z0-808)
Support de cours
Formation OCA Java Se 8 Programmer (1Z0-808) 13
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808) 14
Révision : Généralités…
• Un peu plus qu’un langage de programmation:
• “gratuit”!
• Indépendant de la plateforme
• Langage interprété et byte code
• Portable
• Syntaxe à la C
• Orienté objet (classes héritage)
• Nombreuses bibliothèques
• Pas de pointeurs! (ou que des pointeurs!)
• Ramasse-miettes
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808) 15
Plateforme Java
• La compilation génère un .class en bytecode (langage intermédiaire indépendant de la plateforme).
• Le bytecode est interprété par un interpréteur Java JVM
• Java Virtual Machine
Compilation javac
interprétation java
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808) 16
• Indépendance de la plateforme
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808) 17
Plateforme Java : plateforme indépendant de l’OS
• La plateforme java: software au-dessus d’une plateforme exécutable sur un hardware
(exemple MacOs, linux …)
• Java VM
• Java application Programming Interface (Java API):
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808) 18
Java ,tout un environnement…
• JDK: Java Developpement Kit
• JRE : Java Runtime Environment
• Java compiler,Java Debugger
• RMI ,Awt , Swing, Internal and external API(Application programmable interface )
• IDE ( eclipse ,Netbeans, jdeveloper )
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808) 19
Utilisation du langage Java pour développer:
• Une application avec interface graphique
• Une application Android
• Java Enterprise Edition JEE6,7,8..,etc..
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
1- Téléchargement et installation du JDK 1.8
2- Configuration de la variable d'environnement
JAVA_HOME
3- Compilation et exécution d’une class java
4- Téléchargement Installation Netbeans
Exercice
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
test.java
1 - Créer le fichier test.java sous c:/java
2 – Compiler en byte code le fichier test.java avec la commande Javac
javac test.java
3 – java test
public class test {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("hello");
}
}
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Principes de base de la Programmation orientée objet
Classe : Représente le modèle
Une classe a des champs nommé attribut
Une classe a des fonction appelé méthodes
L’appel d’une classe est appelé instanciation ,le résultat de
Cet appel est appelé un objet
Exemple:
Voiture a un vitesse x , un prix y, un modèle z
La voiture roule: ( action)
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Implémentation de la classe voiture
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Les identifiants légaux ( Legal Identifiers )
1 . Identifiers must start with a letter, a currency character ($), or a
Connecting character such as the underscore ( _ ).
Identifiers cannot start with a number!
After the first character, identifiers can contain any combination of letters,
currency characters, connecting characters, or numbers.
Enum Identifiers in Java are case-sensitive;
foo and COLLIE ,collie are two different identifiers.
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
On ne peut pas utiliser le mot Java comme identifiant an identifier.
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
General code best practice ( Les bonnes pratique de coding en Java )
Classes and interfaces The first letter should be capitalized:
Example for classes: Dog
Account
PrintWriter
Example for interfaces : Runnable
Serializable
Example for methodes : getBalance
get/set/is doCalculation
setCustomerName
Variables (miniscule): buttonWidth
accountBalance
Constants (majuscule) ex :static, final : MIN_HEIGHT
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Une seule classe public dans un fichier .java
1 - There can be only one public class per source code file.
2 - A file can have more than one nonpublic class.
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Access modifiers ( Les Modificateurs d'accès )
class MyClass { }
Access modifiers: public, protected, private, package (par défaut )
Variable , méthode & classe
Class :
Public : La classe est accessible pour toute les classes du projet
Package: La classe est accessible par toute les classes du même package
Protected /private pas de sens
Ordre de visibilité : Classe, méthode, variable
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Visibilité
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Visibilité
Private < package < Protected < Public
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
If there is a public class in a file, the name of the file must match the name
of the public class. For example, a class declared as public class Dog { }
must be in a source code file named Dog.java.
Les bonnes pratiques de coding ( Coding est practice )
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Import de la classe Beverage
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Commentaire // Comments
// comment until end of line
/* Multiple
* line comment
*/
Raccourcit : ctrl + alt+ c
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Import des classes // Class imports
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
import des classes // Concept package :
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Concept package : import des classes
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Constructor Declarations ( la déclaration des contructeurs )
In Java, objects are constructed. Every time you make a new object, at least one
constructor is invoked. Every class has a constructor, although if you don't create
one explicitly, the compiler will build one for you. There are tons of rules concerning
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Block d’initialisation // Instance Initializer Blocks
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Lab : initialization bloc (Block d’initialisation )
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Lab : initialization bloc
Resultat : 5
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Les identifiants / / Identifiers
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Apprendre les valeurs par défaut des variables
Understanding Default Initialization of Variables
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Le scope de la variable // Variables scope
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Le ramasse miette // Garbage Collection
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Remember, finalize() is only run when the object is eligible for garbage collection.
Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Exercice du premier chapitre
Chapter 1 questions
Chapitre 1 : Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 1 : Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 1 : Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 1 : Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 1 : Java Building Blocks
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 1 : Java Building Blocks
Liste des exercices
Page 42
OCA Oracle
Certified Associate
Java SE 8 Programmer I
Study Guide Exam 1Z0-808
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Default litervals for int, long ,float , double
Les valeurs par défault pour int, long , float, double
byte < short < int < long : entier
float < double : réel
Toute valeur entier est considéré comme un int
Toute valeur réel est considéré comme un double
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Comprendre les operateurs java
Understanding Java Operators
int y = 4;
double x = 3 + 2 * --y;
Result of x
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Comprendre les operateurs java
Understanding Java Operators
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Comprendre les operateurs java
Understanding Java Operators
Formation OCA Java Se 8 Programmer (1Z0-808)
Arithmetic Operators
Les operateurs arithmétique
int x = 2 * 5 + 3 * 4 - 8;
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Arithmetic operators are often encountered in early mathematics and include addition
(+), subtraction (-), multiplication (*), division (/), and modulus (%). They also include the
As you may have noticed in Table 2.1, the multiplicative operators (*, /, %) have a higher order of
precedence
than the additive operators (+, -). That means when you see an expression such as this:
int x = 2 * 5 + 3 * 4 - 8;
You first evaluate the 2 * 5 and 3 * 4, which reduces the expression to the following:
int x = 10 + 12 - 8;
Then, you evaluate the remaining terms in left-to-right order, resulting in a value of x of 14.
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Arithmetic Operators
Les operateurs arithmétique
Formation OCA Java Se 8 Programmer (1Z0-808)
int x = 2 * ((5 + 3) * 4 – 8);
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Notice that we said “Unless overridden with parentheses…”.
That’s because you can change the order of operation explicitly by wrapping parentheses around the sections
you want evaluated first. Compare the previous example with the following
one containing the same values and operators, in the same order, but with two sets of
parentheses:
int x = 2 * ((5 + 3) * 4 – 8);
This time you would evaluate the addition operator 10 + 3, which reduces the expression
to the following:
int x = 2 * (8 * 4 – 8);
You can further reduce this expression by multiplying the first two values within the
parentheses:
int x = 2 * (32 – 8);
Next, you subtract the values within the parentheses before applying terms outside the
parentheses:
int x = 2 * 24;
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
System.out.print(9 / 3);
System.out.print(9 % 3);
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Numeric Promotion Rules ( Règles de promotion numérique )
1. If two values have different data types, Java will automatically promote one of the values to the larger of the two data types
Si on a deux valeurs de type de donnée différent, java va automatiquement adapter un des deux valeurs vers le type de
donnée le plus large.
.
2. If one of the values is integral and the other is floating-point, Java will automatically promote the integral value to the floating-
point value’s data type.
Si on deux valeurs, le premier est de type entier, le deuxième est de type réel , Java va adapter automatiquement la valeur
de type entier en une valeur de type réel
3. Smaller data types, namely byte, short, and char, are first promoted to int any time they’re used with a Java binary arithmetic
operator, even if neither of the operands is int.
Les données les plus petit à savoir byte, short, and char, vont etre adapter avec les opérations arithmétique vers le type de
donnée entier meme si aucun des deux valeurs est de type entier
4. After all promotion has occurred and the operands have the same data type, the resulting value will have the same data type as its
promoted operands.
- Le type de donnée de la valeur du résultat va s’adapter au des deux type de donnée de l’opération
Chapitre 2 : Operators and Statements
Formation OCA Java Se 8 Programmer (1Z0-808)
What is the data type of x * y?
int x = 1;
long y = 33;
What is the data type of x + y?
double x = 39.21;
float y = 2.1;
Numeric Promotion Rules
Règles de promotion numérique
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
What is the data type of x * y?
int x = 1;
long y = 33;
If we follow the first rule, since one of the values is long and the other is int, and long
is larger than int, then the int value is promoted to a long, and the resulting value is long.
What is the data type of x + y?
double x = 39.21;
float y = 2.1;
This is actually a trick question, as this code will not compile! As you may remember
from Chapter 1, floating-point literals are assumed to be double, unless post fixed with an f, as in 2.1f. If the value
was set properly to 2.1f, then the promotion would be similar to the last example, with both operands being
promoted to a double, and the result would be a double value.
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
What is the data type of x / y?
short x = 10;
short y = 3;
What is the data type of x * y / z?
short x = 14;
float y = 13;
double z = 30;
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
What is the data type of x / y?
short x = 10;
short y = 3;
In this case, we must apply the third rule, namely that x and y will both be promoted
to int before the operation, resulting in an output of type int. Pay close attention to
the fact that the resulting output is not a short, as we’ll come back to this example in
the upcoming section on assignment operators.
¦
What is the data type of x * y / z?
short x = 14;
float y = 13;
double z = 30;
In this case, we must apply all of the rules. First, x will automatically be promoted to int solely because it is a short
and it is being used in an arithmetic binary operation.
The promoted x value will then be automatically promoted to a float so that it can be
multiplied with y. The result of x * y will then be automatically promoted to a double,
so that it can be multiplied with z, resulting in a double value.
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Les opérateurs unaire
Formation OCA Java Se 8 Programmer (1Z0-808)
The logical complement operator ! ( l’opérateur logique complémentaire ! )
boolean x = false;
System.out.println(x);
x = !x;
System.out.println(x);
Likewise, the negation operator, -, reverses the sign of a numeric expression, as shown in these statements:
System.out.println(x); // 1.21
x = -x;
System.out.println(x); // -1.21
x = -x;
System.out.println(x); // 1.21
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
int x = !5;
boolean y = -true
boolean z = !0;
Will this run ?
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
The following code snippet illustrates this distinction:
int counter = 0;
System.out.println(counter); // Outputs 0
System.out.println(++counter); // Outputs 1
System.out.println(counter); // Outputs 1
System.out.println(counter--); // Outputs 1
System.out.println(counter); // Outputs 0
The first pre-increment operator updates the value for counter and outputs the new
value of 1. The next post-decrement operator also updates the value of counter but outputs
the value before the decrement occurs.
One common practice in a certification exam, is to apply multiple increment or decrement operators to a single
variable on the same line:
int x = 3;
int y = ++x * 5 / x-- + --x;
System.out.println("x is " + x);
System.out.println("y is " + y);
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Increment and Decrement Operators
Les opérateurs d’incrementation et de décrementation
Formation OCA Java Se 8 Programmer (1Z0-808)
Increment and Decrement Operators
Les opérateurs d’incrémentation et de décrémentation
int x = 3;
int y = ++x * 5 / x-- + --x;
System.out.println("x is " + x);
System.out.println("y is " + y);
So how do you read this code? First, the x is incremented and returned to the expression,
which is multiplied by 5. We can simplify this:
int y = 4 * 5 / x-- + --x; // x assigned value of 4
Next, x is decremented, but the original value of 4 is used in the expression, leading to
this:
int y = 4 * 5 / 4 + --x; // x assigned value of 3
The assignment of x reduces the value to 2, and since this is a pre-increment operator,
that value is returned to the expression:
int y = 4 * 5 / 4 + 2; // x assigned value of 2
Finally, we evaluate the multiple and division from left-to-right, and finish with the addition.
The result is then printed:
x is 2
y is 7
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Increment and Decrement Operators
Les opérateurs d’incrementation et de décrementation
Int x = 5
System.out.println( ++x + x + x++ + x + x + x++ );
Formation OCA Java Se 8 Programmer (1Z0-808)
Increment and Decrement Operators
Les opérateurs d’incrementation et de décrementation
Int x = 5
++ x : pre-incrementation ( pre-increment operator ) :
L’operateur d’incrementation est appliqué et la nouvelle valeur de x est mis à jour
x++ : post-incrementation ( post-increment operator ):
La valeur d’origine de x est affichée et l’operateur d’incrementation est appliqué au prochain
traitement ou affichage .
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Les operateurs d’affectation (Assignment Operators )
Chapitre 2 : Operators and Statements
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Casting des types primitive
Formation OCA Java Se 8 Programmer (1Z0-808)
short x = 10;
short y = 3;
short z = x * y;
Will this compile
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
short x = 10;
short y = 3;
short z = (short)(x * y);
short values are automatically promoted to int when applying any arithmetic operator,
with the resulting value being of type int. Trying to set a short variable to an int results in a
compiler error, as Java thinks you are trying to implicitly convert from a larger data type to
a smaller one.
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Compound Assignment Operators ( Les opérateurs d’affectation composées )
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Relational Operators ( les opérateurs relationnel )
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Logical Operators (Les opérateurs logiques)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Logical operators
Les opérateurs logique
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
int x = 6;
boolean y = (x >= 6) || (++x <= 7);
System.out.println(x);
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Logical operators
Les opérateurs logique
Formation OCA Java Se 8 Programmer (1Z0-808)
int x = 6;
boolean y = (x >= 6) || (++x <= 7);
System.out.println(x);
Because x >= 6 is true, the increment operator on the right-hand side of the expression
is never evaluated, so the output is 6.
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Logical operators
Les opérateurs logique
Formation OCA Java Se 8 Programmer (1Z0-808)
Equality Operators ( Opérateurs d'égalité )
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Understanding Java Statements
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Ternary Operator
Opérateur Ternaire
Formation OCA Java Se 8 Programmer (1Z0-808)
int y = 1;
int z = 1;
final int x = y<10 ? y++ : z++;
System.out.println(y+","+z);
Chapitre 2 : Operators and Statements
Ternary Operator
Opérateur Ternaire
Formation OCA Java Se 8 Programmer (1Z0-808)
int y = 1;
int z = 1;
final int x = y<10 ? y++ : z++;
System.out.println(y+","+z);
// Outputs 2,1
Notice that since the left-hand boolean expression was true, only y was
incremented.
Contrast the preceding example with the following modifi cation
Chapitre 2 : Operators and Statements
Ternary Operator
Opérateur Ternaire
Formation OCA Java Se 8 Programmer (1Z0-808)
int y = 1;
int z = 1;
final int x = y>=10 ? y++ : z++;
System.out.println(y+","+z);
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Ternary Operator
Opérateur Ternaire
Formation OCA Java Se 8 Programmer (1Z0-808)
int y = 1;
int z = 1;
final int x = y>=10 ? y++ : z++;
System.out.println(y+","+z);
// Outputs 1,2
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Ternary Operator
Opérateur Ternaire
Formation OCA Java Se 8 Programmer (1Z0-808)
Switch case
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808) 100
While and do
• while
• ++ expression of a while loop must be declared before the expression is evaluated
 illegal: while (boolean x = true) {}
• The expression result must be a boolean
• do
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808) 101
While
int x = 2;
int y = 5;
while(x < 10)
y++; ?
Boucle infinie
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808) 102
Do , While
int x = 0;
do {
x++;
}
while(false);
System.out.println(x);
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808) 103
Do , While
int x = 0;
do {
x++;
}
while(false);
System.out.println(x);
// Outputs 1
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808) 104
Do , While
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Will this compile
for(int i = 0; i < 10; i++) {
System.out.print(i + " ");
}
Will this compile
for( ; ; ) {
System.out.println("Hello World");
}
?
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Adding Multiple Terms to the for Statement
int x = 0;
for( long y = 0, z = 4; x < 5 && y < 10; x++, y++)
{
System.out.print(y + " ");
}
System.out.print(x);
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
int x = 0;
for(long y = 0, x = 4; x < 5 && y < 10; x++, y++) {
System.out.print(x + " ");
}
What do you think
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
We can fix this loop by changing the declaration of x and y as follows:
int x = 0;
long y = 10;
for(y = 0, x = 4; x < 5 && y < 10; x++, y++) {
System.out.print(x + " ");
}
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
for(long y = 0, int x = 4; x < 5 && y<10; x++, y++) {
System.out.print(x + " ");
}
What do yo think ?
Declaring long y and int x
Déclaration de long y et de int x
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Using Loop Variables Outside the Loop
Utlisation d’une variable déclaré dans une boucle à l’exterieur du boucle
for(long y = 0, x = 4; x < 5 && y < 10; x++, y++) {
System.out.print(y + " ");
}
System.out.print(x);
What do you think
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Operators and Statements
Enhanced loop ~ boucle for amélioré
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Operators and Statements
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Operators and Statements
Enhanced loop ~ boucle for amélioré
Formation OCA Java Se 8 Programmer (1Z0-808)
Nested Loops ( les boucles imbriquées )
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Nested loops can include while and do-while, as shown in this example.
See if you can
determine what this code will output.
int x = 20;
while(x>0) {
do {
x -= 2
} while (x>5);
x--;
System.out.print(x+"t");
}
Nested Loops ( les boucles imbriquées )
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Optional labels ( les labels optionnelles )
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
break statement transfers the fow of control out to the enclosing statement , Break with a label
break transfer le control de flux à l’extérieur du bloc d’instruction actuel , Break avec un label
Formation OCA Java Se 8 Programmer (1Z0-808)
Optional labels ( les labels optionnelles )
break statement transfers the fow of control out to the enclosing statement , Break with a label
break transfer le control de flux à l’extérieur du bloc d’instruction actuel , Break avec un label
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Let’s now complete our discussion of advanced loop control with the continue statement, astatement that
causes how to finish the execution of the current loop ( current interation ),
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
break permet de transférer le control à l'extérieur du bloc
d’intruction actuel, continue permet de d’arreter le
traitement actuel and passer à la prochaine intération
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
continue with a label
continue without a label
continue avec un label
continues sans label
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
break with a label
Break avec un label
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Exam questions
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Liste des exercices
Page 94
OCA Oracle
Certified Associate
Java SE 8 Programmer I
Study Guide Exam 1Z0-808
Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
What’s the output
int three = 3;
String four = "4";
System.out.println(1 + 2 + three + four);
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
++ Strings Are Immutable Objects
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Once a String object is created, it is not allowed to change. It cannot be made larger or
smaller, and you cannot change one of the characters inside it.
Le moment ou l’objet string est crée, il est pas possible de le changer.
Apercu sur la mémoire
Formation OCA Java Se 8 Programmer (1Z0-808)
++ Strings Are Immutable Objects
String name = "Fluffy";
name = "anis";
System.out.println(name);
What’s the output
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
++ Strings Are Immutable Objects
String name = "Fluffy";
name = "anis";
System.out.println(name);
== >
String name = "Fluffy";
name = new String(" anis ")
System.out.println(name);
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
String Class methodes – page 105
Les méthodes de la classe String
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Which one compiles ?
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
String Object is length()
For tables it is length
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
The StringBuffer and StringBuilder Classes
The java.lang.StringBuffer and java.lang.StringBuilder classes should be used when you have to make a lot of
modifications to strings of characters
As we discussed in the previous section, String objects are immutable, so if you choose to do a lot of
manipulations with String objects, you will end up with a lot of abandoned String objects in the String pool
(waste precious memory )
objects of type StringBuffer and StringBuilder can be modified over and over again without leaving behind a
great effluence of discarded String objects
Oracle recommends that you use StringBuilder instead of StringBuffer whenever possible because
StringBuilder will run faster (and perhaps jump higher).
anything we say about StringBuilder's methods holds true for StringBuffer's methods .
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
We got a nice new String out of the deal, but the downside is that the old String
abc" has been lost in the String pool, thus wasting memory. If we were using a
StringBuffer instead of a String, the code would look like this:
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Example of some methodes of the StringBuilder Classes - Page 114
Exemple des méthodes de la classe StringBuilder - Page 114
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Understanding Equality
Comprendre l’égalité
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Understanding Equality ( with reference or with equals methode
Comprendre l’égalité ( avec la référence ou par la méthode equals )
Formation OCA Java Se 8 Programmer (1Z0-808)
Understanding Java Arrays
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
int[] numbers2 = {42, 55, 99};
Finally, you can type the [] before or after the name, and
adding a space is optional.
This means that all four of these statements do the exact same
thing:
int[] numAnimals;
int [] numAnimals2;
int numAnimals3[];
int numAnimals4 [];
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Array Declarations ~ déclaration d’un tableau
In Java, arrays are objects that store multiple variables of the same type,
or variables that are all subclasses of the same type.
Arrays can hold either primitives or object
We can also declare multidimensional arrays, which are in fact arrays of arrays.
This can be done in the following manner:
String[][][] occupantName;
String[] managerName [];
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Exemple, pour allouer une matrice de 5 lignes de 6 colonnes
Int [ ] [ ] matrice = new int [5] [6]
Une autre manière :
int[][] matrice = {
{ 0, 1, 4, 3 } , // tableau [0] de int
{ 5, 7, 9, 11, 13, 15, 17 } // tableau [1] de int };
int i, j; for(i=0; i<matrice.length; i++)
{ for(j=0; j<matrice[i].length; j++)
{ //Action sur matrice[i][j] } }
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Array Declarations ~ déclaration d’un tableau
Formation OCA Java Se 8 Programmer (1Z0-808) 153
• Public String toString()
• Returns a "text representation" of the object.
• Can override to explain the class.
• void finalize()
• Called by garbage collector when the garbage collector sees that the object cannot be referenced.
• final void notify()
• Wakes up a thread that is waiting for this object's lock.
• final void notifyAll ()
• Wakes up all threads that are waiting for this object's lock.
• final void wait()
• Pauses the current thread to wait until another thread calls notify() or notifyAll() on this subject.
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Object class methods ~ les méthodes de la class Object
Formation OCA Java Se 8 Programmer (1Z0-808)
when we don’t override toString ~ lorsque qu’on redéfinit pas la méthode ToString()
Hashcode : objectid
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
when we override toString ~ lorsqu’on redéfinit pas la méthode ToString()
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
What about this ?
String[] birds = new String[6];
System.out.println(birds.length);
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Using an Array ~ utilisation d’un tableau
Formation OCA Java Se 8 Programmer (1Z0-808)
Sorting ~ le Tri
import java.util.* // import whole package including Arrays
import java.util.Arrays; // import just Arrays
The result is ?
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Trying this again with String types // Essaie du tri avec les types String :
String[] strings = { "10", "9", "100" };
Arrays.sort(strings);
for (String string : strings)
System.out.print(string + " ");
What’s the output
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Theproblem is that String sorts in alphabetic order, and 1 sorts before 9.
(Numbers sort before letters and uppercase sorts before lowercase, in case you
were wondering.)
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Creating a multidimensionnal Array // creation d’un tableau à deux dimension
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Searching // la recherche
Formation OCA Java Se 8 Programmer (1Z0-808)
Varagrs // argument variable
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Methods with variable argument Lists ( vars-args)
Méthodes avec des arguments variable ( vars-args
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Methods with variable argument Lists ( vars-args)
Méthodes avec des arguments variable ( vars-args
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Understanding an ArrayList
Comprendre les ArrayList
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Creating an ArrayList
La creation d’un ArrayList
Formation OCA Java Se 8 Programmer (1Z0-808)
the new and improved way. Java 5 introduced generics, which allow you to
specify the type of class that the ArrayList will contain.
Java 5 a introduit les generics qui vont permettre de spécifier le type de
donnée d’une liste
ArrayList <String> list4 = new ArrayList<String>();
ArrayList <String> list5 = new ArrayList<>();
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Add method // la méthode Add
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
remove method // la méthode remove
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
set method // la méthode set
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
isEmpty() and size() method // la méthode Add isEmpty() et size()
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
clear method // la méthode clear
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
contains method // la méthode contains
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
equals method // la méthode equals
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Converting between array and List
La conversion entre un tableau ( array) et une liste
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Sorting // le tri
Formation OCA Java Se 8 Programmer (1Z0-808)
The wrapper classes in the Java API serve two primary purposes:
Up to now, we’ve only put String objects in the ArrayList. What happens if we want to put primitives in?
Each primitive type has a wrapper class, which is an object type that
There is a wrapper class for every primitive in Java. For instance, the wrapper
class for int is Integer, the class for float is Float, and so on. Remember that
the primitive name is simply the lowercase name of the wrapper except for char,
which maps to Character, and int, which maps to Integer. Table 3-2 lists the
wrapper classes in the Java API.
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
1
Overview // Apercu
• boolean | Boolean | boolean or String
• byte | Byte | byte or String
• char | Character | char
• double | Double | double or String
• float | Float | float, double, or String
• short | Short | short or String
• int | Integer | int or String
• long | Long | long or String
• Wrapper objects are immutable, as String, value can’t change
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Declaration of a Wrapper Object
La déclaration d’un Wrapper Object
Formation OCA Java Se 8 Programmer (1Z0-808)
183
When you need to convert the value of a wrapped numeric to a primitive, use one of
the many xxxValue() methods
 primitive xxxValue()
◦ to convert a Wrapper to a primitive: int x = xxWrapper.intValue();
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Wrapper Conversion Utilities
les outils de conversion des Wrapper class
Formation OCA Java Se 8 Programmer (1Z0-808)
184
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Declaration of a Wrapper Object
La déclaration d’un Wrapper Object
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Wrapper coversion table ,page 243
Table de conversion des Wrapper
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Wrapper are immutable
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Y++
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
The API developers decided that for all the wrapper classes, two
objects are equal if they are of the same type and have the same value. It shouldn't be surprising that
== check if the object is same, equals() check the value
Autoboxing
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
== check if the object is same, equals() check the value
Autoboxing
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Example of Boxing
Exemple d’utilisation du Boxing
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Conversion between Array and List
Conversion entre Arrays et List
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Conversion between Array and List
Conversion entre Arrays et List
Formation OCA Java Se 8 Programmer (1Z0-808)
Working with Dates and Times
Utilisaiton du Dates et Times
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Working with Dates and Times
Utilisaiton du Dates et Times
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Working with Dates and Times
Utilisaiton du Dates et Times
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Manipulation Dates and Times
Utilisation du Dates et Times
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Manipulation Dates and Times
Utilisation du Dates et Times
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Manipulation Dates and Times
Utilisation du Dates et Times
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Working with Periods
Utilisation des Periode
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Working with Periods
Utilisation des Periode
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formatting Date and Time
Personnalisé la date et le temp
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formatting Date and Time
Personnalisé la date et le temp
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Formatting Date and Time
Personnalisé la date et le temp
Formation OCA Java Se 8 Programmer (1Z0-808)
Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
Parsing Date and Time
Parcourir la date et le temp

Contenu connexe

Tendances

Administration des base de donnees sous oracle 10g
Administration des base de donnees sous oracle 10g Administration des base de donnees sous oracle 10g
Administration des base de donnees sous oracle 10g noble Bajoli
 
POO Java Chapitre 4 Heritage et Polymorphisme
POO Java Chapitre 4 Heritage et PolymorphismePOO Java Chapitre 4 Heritage et Polymorphisme
POO Java Chapitre 4 Heritage et PolymorphismeMouna Torjmen
 
Marzouk architecture encouches-jee-mvc
Marzouk architecture encouches-jee-mvcMarzouk architecture encouches-jee-mvc
Marzouk architecture encouches-jee-mvcabderrahim marzouk
 
Workshop spring session 2 - La persistance au sein des applications Java
Workshop spring   session 2 - La persistance au sein des applications JavaWorkshop spring   session 2 - La persistance au sein des applications Java
Workshop spring session 2 - La persistance au sein des applications JavaAntoine Rey
 
Chapitre 6 traitement des exceptions
Chapitre 6  traitement des exceptionsChapitre 6  traitement des exceptions
Chapitre 6 traitement des exceptionsAmir Souissi
 
Introduction à spring boot
Introduction à spring bootIntroduction à spring boot
Introduction à spring bootAntoine Rey
 
Chap 6 : classes et interfaces
Chap 6 : classes et interfacesChap 6 : classes et interfaces
Chap 6 : classes et interfacesAziz Darouichi
 
Exercice 1 java Héritage
Exercice 1 java HéritageExercice 1 java Héritage
Exercice 1 java HéritageNadaBenLatifa
 

Tendances (20)

Les collections en Java
Les collections en JavaLes collections en Java
Les collections en Java
 
Support programmation orientée objet c# .net version f8
Support programmation orientée objet c#  .net version f8Support programmation orientée objet c#  .net version f8
Support programmation orientée objet c# .net version f8
 
Administration des base de donnees sous oracle 10g
Administration des base de donnees sous oracle 10g Administration des base de donnees sous oracle 10g
Administration des base de donnees sous oracle 10g
 
POO Java Chapitre 4 Heritage et Polymorphisme
POO Java Chapitre 4 Heritage et PolymorphismePOO Java Chapitre 4 Heritage et Polymorphisme
POO Java Chapitre 4 Heritage et Polymorphisme
 
Marzouk architecture encouches-jee-mvc
Marzouk architecture encouches-jee-mvcMarzouk architecture encouches-jee-mvc
Marzouk architecture encouches-jee-mvc
 
Java
JavaJava
Java
 
Sécurité des Applications Web avec Json Web Token (JWT)
Sécurité des Applications Web avec Json Web Token (JWT)Sécurité des Applications Web avec Json Web Token (JWT)
Sécurité des Applications Web avec Json Web Token (JWT)
 
Cours JavaScript
Cours JavaScriptCours JavaScript
Cours JavaScript
 
Programmation sous Android
Programmation sous AndroidProgrammation sous Android
Programmation sous Android
 
Workshop spring session 2 - La persistance au sein des applications Java
Workshop spring   session 2 - La persistance au sein des applications JavaWorkshop spring   session 2 - La persistance au sein des applications Java
Workshop spring session 2 - La persistance au sein des applications Java
 
Polymorphisme (cours, résumé)
Polymorphisme (cours, résumé)Polymorphisme (cours, résumé)
Polymorphisme (cours, résumé)
 
Support de Cours JSF2 Première partie Intégration avec Spring
Support de Cours JSF2 Première partie Intégration avec SpringSupport de Cours JSF2 Première partie Intégration avec Spring
Support de Cours JSF2 Première partie Intégration avec Spring
 
Chapitre 6 traitement des exceptions
Chapitre 6  traitement des exceptionsChapitre 6  traitement des exceptions
Chapitre 6 traitement des exceptions
 
Nouveautés de java 8
Nouveautés de java 8Nouveautés de java 8
Nouveautés de java 8
 
Support de cours Spring M.youssfi
Support de cours Spring  M.youssfiSupport de cours Spring  M.youssfi
Support de cours Spring M.youssfi
 
JAVA
JAVAJAVA
JAVA
 
Introduction à spring boot
Introduction à spring bootIntroduction à spring boot
Introduction à spring boot
 
Chap 6 : classes et interfaces
Chap 6 : classes et interfacesChap 6 : classes et interfaces
Chap 6 : classes et interfaces
 
Tp n 5 linux
Tp n 5 linuxTp n 5 linux
Tp n 5 linux
 
Exercice 1 java Héritage
Exercice 1 java HéritageExercice 1 java Héritage
Exercice 1 java Héritage
 

Similaire à Support formation vidéo : OCA Java SE 8 Programmer (1Z0-808) (1)

Formation JAVA (1)
Formation JAVA (1)Formation JAVA (1)
Formation JAVA (1)Ahmed Charef
 
Seance_1_cours_introduction_java_Copie.pptx
Seance_1_cours_introduction_java_Copie.pptxSeance_1_cours_introduction_java_Copie.pptx
Seance_1_cours_introduction_java_Copie.pptxRihabBENLAMINE
 
introductionaudevcomposantdistribuejavaee.pdf
introductionaudevcomposantdistribuejavaee.pdfintroductionaudevcomposantdistribuejavaee.pdf
introductionaudevcomposantdistribuejavaee.pdfHamdaneAbdelAzizHagg
 
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !Paris Salesforce Developer Group
 
Java-Introduction (1).pdf
Java-Introduction (1).pdfJava-Introduction (1).pdf
Java-Introduction (1).pdfKuateTanguy2
 
Java 2015 2016_zied_elleuch
Java 2015 2016_zied_elleuchJava 2015 2016_zied_elleuch
Java 2015 2016_zied_elleuchTarek Halloul
 
Architecture java j2 ee a partager
Architecture java j2 ee a partagerArchitecture java j2 ee a partager
Architecture java j2 ee a partageraliagadir
 
Présentation de JEE et de son écosysteme
Présentation de JEE et de son écosystemePrésentation de JEE et de son écosysteme
Présentation de JEE et de son écosystemeStéphane Traumat
 
Alphorm.com Formation Java,avancé OCP (1Z0-804)
Alphorm.com Formation Java,avancé OCP (1Z0-804)Alphorm.com Formation Java,avancé OCP (1Z0-804)
Alphorm.com Formation Java,avancé OCP (1Z0-804)Alphorm
 
Java 110605092007-phpapp02
Java 110605092007-phpapp02Java 110605092007-phpapp02
Java 110605092007-phpapp02Eric Bourdet
 
Java uik-chap1-intro java
Java uik-chap1-intro javaJava uik-chap1-intro java
Java uik-chap1-intro javaAmel Morchdi
 
Play Framework
Play FrameworkPlay Framework
Play FrameworkArmaklan
 
1-supportpoojavapremirepartie-140408132307-phpapp01.pptx
1-supportpoojavapremirepartie-140408132307-phpapp01.pptx1-supportpoojavapremirepartie-140408132307-phpapp01.pptx
1-supportpoojavapremirepartie-140408132307-phpapp01.pptxRihabBENLAMINE
 
POO Licence L2 Partie I.pdf
POO Licence L2 Partie I.pdfPOO Licence L2 Partie I.pdf
POO Licence L2 Partie I.pdfLarbaSAWADOGO2
 

Similaire à Support formation vidéo : OCA Java SE 8 Programmer (1Z0-808) (1) (20)

Formation JAVA (1)
Formation JAVA (1)Formation JAVA (1)
Formation JAVA (1)
 
Seance_1_cours_introduction_java_Copie.pptx
Seance_1_cours_introduction_java_Copie.pptxSeance_1_cours_introduction_java_Copie.pptx
Seance_1_cours_introduction_java_Copie.pptx
 
introductionaudevcomposantdistribuejavaee.pdf
introductionaudevcomposantdistribuejavaee.pdfintroductionaudevcomposantdistribuejavaee.pdf
introductionaudevcomposantdistribuejavaee.pdf
 
Programmation Java
Programmation JavaProgrammation Java
Programmation Java
 
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
 
Chap 02 poo en java
Chap 02 poo en javaChap 02 poo en java
Chap 02 poo en java
 
Java-Introduction (1).pdf
Java-Introduction (1).pdfJava-Introduction (1).pdf
Java-Introduction (1).pdf
 
Java 2015 2016_zied_elleuch
Java 2015 2016_zied_elleuchJava 2015 2016_zied_elleuch
Java 2015 2016_zied_elleuch
 
Java j2ee
Java j2eeJava j2ee
Java j2ee
 
Architecture java j2 ee a partager
Architecture java j2 ee a partagerArchitecture java j2 ee a partager
Architecture java j2 ee a partager
 
Présentation de JEE et de son écosysteme
Présentation de JEE et de son écosystemePrésentation de JEE et de son écosysteme
Présentation de JEE et de son écosysteme
 
Alphorm.com Formation Java,avancé OCP (1Z0-804)
Alphorm.com Formation Java,avancé OCP (1Z0-804)Alphorm.com Formation Java,avancé OCP (1Z0-804)
Alphorm.com Formation Java,avancé OCP (1Z0-804)
 
Introduction JavaEE
Introduction JavaEEIntroduction JavaEE
Introduction JavaEE
 
Java 110605092007-phpapp02
Java 110605092007-phpapp02Java 110605092007-phpapp02
Java 110605092007-phpapp02
 
Java uik-chap1-intro java
Java uik-chap1-intro javaJava uik-chap1-intro java
Java uik-chap1-intro java
 
Nouveautés Java 9-10-11
Nouveautés Java 9-10-11Nouveautés Java 9-10-11
Nouveautés Java 9-10-11
 
Play Framework
Play FrameworkPlay Framework
Play Framework
 
1-supportpoojavapremirepartie-140408132307-phpapp01.pptx
1-supportpoojavapremirepartie-140408132307-phpapp01.pptx1-supportpoojavapremirepartie-140408132307-phpapp01.pptx
1-supportpoojavapremirepartie-140408132307-phpapp01.pptx
 
Javaoop
JavaoopJavaoop
Javaoop
 
POO Licence L2 Partie I.pdf
POO Licence L2 Partie I.pdfPOO Licence L2 Partie I.pdf
POO Licence L2 Partie I.pdf
 

Plus de SmartnSkilled

Formation : Comment rendre une réunion efficace ?
Formation : Comment rendre une réunion efficace ?Formation : Comment rendre une réunion efficace ?
Formation : Comment rendre une réunion efficace ?SmartnSkilled
 
Support cours : Les Data Sciences avec Python Langage - Partie II
Support cours : Les Data Sciences avec Python Langage - Partie IISupport cours : Les Data Sciences avec Python Langage - Partie II
Support cours : Les Data Sciences avec Python Langage - Partie IISmartnSkilled
 
Support tutoriel : Initiation à SAP ERP
Support tutoriel : Initiation à SAP ERPSupport tutoriel : Initiation à SAP ERP
Support tutoriel : Initiation à SAP ERPSmartnSkilled
 
Support formation : Construire et administrer vos conteneurs avec Docker
Support formation : Construire et administrer vos conteneurs avec DockerSupport formation : Construire et administrer vos conteneurs avec Docker
Support formation : Construire et administrer vos conteneurs avec DockerSmartnSkilled
 
Support formation : Maîtriser la comptabilité des opérations de fin d'exercice
Support formation : Maîtriser la comptabilité des opérations de fin d'exerciceSupport formation : Maîtriser la comptabilité des opérations de fin d'exercice
Support formation : Maîtriser la comptabilité des opérations de fin d'exerciceSmartnSkilled
 
Support cours : Comment rédiger un rapport ?
Support cours : Comment rédiger un rapport ?Support cours : Comment rédiger un rapport ?
Support cours : Comment rédiger un rapport ?SmartnSkilled
 
Support formation : Maîtriser les Data Sciences avec Python Language - Partie I
Support formation : Maîtriser les Data Sciences avec Python Language - Partie ISupport formation : Maîtriser les Data Sciences avec Python Language - Partie I
Support formation : Maîtriser les Data Sciences avec Python Language - Partie ISmartnSkilled
 
Support cours : Rédigez vos emails professionnels
Support cours : Rédigez vos emails professionnelsSupport cours : Rédigez vos emails professionnels
Support cours : Rédigez vos emails professionnelsSmartnSkilled
 
Support cours : Les phares du marketing
Support cours : Les phares du marketingSupport cours : Les phares du marketing
Support cours : Les phares du marketingSmartnSkilled
 
Support formation : La négociation commerciale coté vendeur
Support formation : La négociation commerciale coté vendeurSupport formation : La négociation commerciale coté vendeur
Support formation : La négociation commerciale coté vendeurSmartnSkilled
 
Support cours : Initiation à SAP ERP
Support cours : Initiation à SAP ERPSupport cours : Initiation à SAP ERP
Support cours : Initiation à SAP ERPSmartnSkilled
 
Tutoriel : Online English Expertise
Tutoriel : Online English ExpertiseTutoriel : Online English Expertise
Tutoriel : Online English ExpertiseSmartnSkilled
 
Formation : Mettre en place une stratégie commerciale
Formation : Mettre en place une stratégie commercialeFormation : Mettre en place une stratégie commerciale
Formation : Mettre en place une stratégie commercialeSmartnSkilled
 
Support cours : Cours d'Espagnol Débutant (A1-A2)
Support cours : Cours d'Espagnol Débutant (A1-A2)Support cours : Cours d'Espagnol Débutant (A1-A2)
Support cours : Cours d'Espagnol Débutant (A1-A2)SmartnSkilled
 
Support cours : Vos premiers pas avec le pare feu CISCO ASA
Support cours : Vos premiers pas avec le pare feu CISCO ASASupport cours : Vos premiers pas avec le pare feu CISCO ASA
Support cours : Vos premiers pas avec le pare feu CISCO ASASmartnSkilled
 
Support Tutoriel : Online English Expertise
Support Tutoriel : Online English ExpertiseSupport Tutoriel : Online English Expertise
Support Tutoriel : Online English ExpertiseSmartnSkilled
 
Support formation en ligne : Manager et auditer les risques informatiques
Support formation en ligne : Manager et auditer les risques informatiquesSupport formation en ligne : Manager et auditer les risques informatiques
Support formation en ligne : Manager et auditer les risques informatiquesSmartnSkilled
 
Support Tutoriel : Art oratoire et prise de parole en public
Support Tutoriel : Art oratoire et prise de parole en publicSupport Tutoriel : Art oratoire et prise de parole en public
Support Tutoriel : Art oratoire et prise de parole en publicSmartnSkilled
 
Support formation en ligne: L'estime de soi
Support formation en ligne: L'estime de soiSupport formation en ligne: L'estime de soi
Support formation en ligne: L'estime de soiSmartnSkilled
 
Support formation vidéo : Les phares du marketing
Support formation vidéo : Les phares du marketingSupport formation vidéo : Les phares du marketing
Support formation vidéo : Les phares du marketingSmartnSkilled
 

Plus de SmartnSkilled (20)

Formation : Comment rendre une réunion efficace ?
Formation : Comment rendre une réunion efficace ?Formation : Comment rendre une réunion efficace ?
Formation : Comment rendre une réunion efficace ?
 
Support cours : Les Data Sciences avec Python Langage - Partie II
Support cours : Les Data Sciences avec Python Langage - Partie IISupport cours : Les Data Sciences avec Python Langage - Partie II
Support cours : Les Data Sciences avec Python Langage - Partie II
 
Support tutoriel : Initiation à SAP ERP
Support tutoriel : Initiation à SAP ERPSupport tutoriel : Initiation à SAP ERP
Support tutoriel : Initiation à SAP ERP
 
Support formation : Construire et administrer vos conteneurs avec Docker
Support formation : Construire et administrer vos conteneurs avec DockerSupport formation : Construire et administrer vos conteneurs avec Docker
Support formation : Construire et administrer vos conteneurs avec Docker
 
Support formation : Maîtriser la comptabilité des opérations de fin d'exercice
Support formation : Maîtriser la comptabilité des opérations de fin d'exerciceSupport formation : Maîtriser la comptabilité des opérations de fin d'exercice
Support formation : Maîtriser la comptabilité des opérations de fin d'exercice
 
Support cours : Comment rédiger un rapport ?
Support cours : Comment rédiger un rapport ?Support cours : Comment rédiger un rapport ?
Support cours : Comment rédiger un rapport ?
 
Support formation : Maîtriser les Data Sciences avec Python Language - Partie I
Support formation : Maîtriser les Data Sciences avec Python Language - Partie ISupport formation : Maîtriser les Data Sciences avec Python Language - Partie I
Support formation : Maîtriser les Data Sciences avec Python Language - Partie I
 
Support cours : Rédigez vos emails professionnels
Support cours : Rédigez vos emails professionnelsSupport cours : Rédigez vos emails professionnels
Support cours : Rédigez vos emails professionnels
 
Support cours : Les phares du marketing
Support cours : Les phares du marketingSupport cours : Les phares du marketing
Support cours : Les phares du marketing
 
Support formation : La négociation commerciale coté vendeur
Support formation : La négociation commerciale coté vendeurSupport formation : La négociation commerciale coté vendeur
Support formation : La négociation commerciale coté vendeur
 
Support cours : Initiation à SAP ERP
Support cours : Initiation à SAP ERPSupport cours : Initiation à SAP ERP
Support cours : Initiation à SAP ERP
 
Tutoriel : Online English Expertise
Tutoriel : Online English ExpertiseTutoriel : Online English Expertise
Tutoriel : Online English Expertise
 
Formation : Mettre en place une stratégie commerciale
Formation : Mettre en place une stratégie commercialeFormation : Mettre en place une stratégie commerciale
Formation : Mettre en place une stratégie commerciale
 
Support cours : Cours d'Espagnol Débutant (A1-A2)
Support cours : Cours d'Espagnol Débutant (A1-A2)Support cours : Cours d'Espagnol Débutant (A1-A2)
Support cours : Cours d'Espagnol Débutant (A1-A2)
 
Support cours : Vos premiers pas avec le pare feu CISCO ASA
Support cours : Vos premiers pas avec le pare feu CISCO ASASupport cours : Vos premiers pas avec le pare feu CISCO ASA
Support cours : Vos premiers pas avec le pare feu CISCO ASA
 
Support Tutoriel : Online English Expertise
Support Tutoriel : Online English ExpertiseSupport Tutoriel : Online English Expertise
Support Tutoriel : Online English Expertise
 
Support formation en ligne : Manager et auditer les risques informatiques
Support formation en ligne : Manager et auditer les risques informatiquesSupport formation en ligne : Manager et auditer les risques informatiques
Support formation en ligne : Manager et auditer les risques informatiques
 
Support Tutoriel : Art oratoire et prise de parole en public
Support Tutoriel : Art oratoire et prise de parole en publicSupport Tutoriel : Art oratoire et prise de parole en public
Support Tutoriel : Art oratoire et prise de parole en public
 
Support formation en ligne: L'estime de soi
Support formation en ligne: L'estime de soiSupport formation en ligne: L'estime de soi
Support formation en ligne: L'estime de soi
 
Support formation vidéo : Les phares du marketing
Support formation vidéo : Les phares du marketingSupport formation vidéo : Les phares du marketing
Support formation vidéo : Les phares du marketing
 

Dernier

Fondation Louis Vuitton. pptx
Fondation      Louis      Vuitton.   pptxFondation      Louis      Vuitton.   pptx
Fondation Louis Vuitton. pptxTxaruka
 
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .Txaruka
 
Présentation_ Didactique 1_SVT (S4) complet.pptx
Présentation_ Didactique 1_SVT (S4) complet.pptxPrésentation_ Didactique 1_SVT (S4) complet.pptx
Présentation_ Didactique 1_SVT (S4) complet.pptxrababouerdighi
 
Cours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSETCours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSETMedBechir
 
Saint Georges, martyr, et la lègend du dragon.pptx
Saint Georges, martyr, et la lègend du dragon.pptxSaint Georges, martyr, et la lègend du dragon.pptx
Saint Georges, martyr, et la lègend du dragon.pptxMartin M Flynn
 
systeme expert_systeme expert_systeme expert
systeme expert_systeme expert_systeme expertsysteme expert_systeme expert_systeme expert
systeme expert_systeme expert_systeme expertChristianMbip
 
Evaluation du systeme d'Education. Marocpptx
Evaluation du systeme d'Education. MarocpptxEvaluation du systeme d'Education. Marocpptx
Evaluation du systeme d'Education. MarocpptxAsmaa105193
 
Le Lean sur une ligne de production : Formation et mise en application directe
Le Lean sur une ligne de production : Formation et mise en application directeLe Lean sur une ligne de production : Formation et mise en application directe
Le Lean sur une ligne de production : Formation et mise en application directeXL Groupe
 
Formation M2i - Comprendre les neurosciences pour développer son leadership
Formation M2i - Comprendre les neurosciences pour développer son leadershipFormation M2i - Comprendre les neurosciences pour développer son leadership
Formation M2i - Comprendre les neurosciences pour développer son leadershipM2i Formation
 
Cours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSETCours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSETMedBechir
 
A3iFormations, organisme de formations certifié qualiopi.
A3iFormations, organisme de formations certifié qualiopi.A3iFormations, organisme de formations certifié qualiopi.
A3iFormations, organisme de formations certifié qualiopi.Franck Apolis
 
BONNES PRATIQUES DE FABRICATION RESUME SIMPLIFIE
BONNES PRATIQUES DE FABRICATION RESUME SIMPLIFIEBONNES PRATIQUES DE FABRICATION RESUME SIMPLIFIE
BONNES PRATIQUES DE FABRICATION RESUME SIMPLIFIEgharebikram98
 
666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx
666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx
666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptxSAID MASHATE
 

Dernier (14)

Fondation Louis Vuitton. pptx
Fondation      Louis      Vuitton.   pptxFondation      Louis      Vuitton.   pptx
Fondation Louis Vuitton. pptx
 
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
 
Présentation_ Didactique 1_SVT (S4) complet.pptx
Présentation_ Didactique 1_SVT (S4) complet.pptxPrésentation_ Didactique 1_SVT (S4) complet.pptx
Présentation_ Didactique 1_SVT (S4) complet.pptx
 
Cours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSETCours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSET
 
Pâques de Sainte Marie-Euphrasie Pelletier
Pâques de Sainte Marie-Euphrasie PelletierPâques de Sainte Marie-Euphrasie Pelletier
Pâques de Sainte Marie-Euphrasie Pelletier
 
Saint Georges, martyr, et la lègend du dragon.pptx
Saint Georges, martyr, et la lègend du dragon.pptxSaint Georges, martyr, et la lègend du dragon.pptx
Saint Georges, martyr, et la lègend du dragon.pptx
 
systeme expert_systeme expert_systeme expert
systeme expert_systeme expert_systeme expertsysteme expert_systeme expert_systeme expert
systeme expert_systeme expert_systeme expert
 
Evaluation du systeme d'Education. Marocpptx
Evaluation du systeme d'Education. MarocpptxEvaluation du systeme d'Education. Marocpptx
Evaluation du systeme d'Education. Marocpptx
 
Le Lean sur une ligne de production : Formation et mise en application directe
Le Lean sur une ligne de production : Formation et mise en application directeLe Lean sur une ligne de production : Formation et mise en application directe
Le Lean sur une ligne de production : Formation et mise en application directe
 
Formation M2i - Comprendre les neurosciences pour développer son leadership
Formation M2i - Comprendre les neurosciences pour développer son leadershipFormation M2i - Comprendre les neurosciences pour développer son leadership
Formation M2i - Comprendre les neurosciences pour développer son leadership
 
Cours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSETCours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSET
 
A3iFormations, organisme de formations certifié qualiopi.
A3iFormations, organisme de formations certifié qualiopi.A3iFormations, organisme de formations certifié qualiopi.
A3iFormations, organisme de formations certifié qualiopi.
 
BONNES PRATIQUES DE FABRICATION RESUME SIMPLIFIE
BONNES PRATIQUES DE FABRICATION RESUME SIMPLIFIEBONNES PRATIQUES DE FABRICATION RESUME SIMPLIFIE
BONNES PRATIQUES DE FABRICATION RESUME SIMPLIFIE
 
666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx
666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx
666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx
 

Support formation vidéo : OCA Java SE 8 Programmer (1Z0-808) (1)

  • 1. Formation OCA Java Se 8 Programmer (1Z0-808) Formation OCA, Java Se 8 Programmer 1Z0-808 Préparée par: Anis HACHANI Formateur et consultant en IT Certifié OCJP, RHCE 6&7, LPI-3, OCE, OCA, OCP Comptia Sec+, Agile ( PSM )
  • 2. Formation OCA Java Se 8 Programmer (1Z0-808) Présentation générale Le programme de certification Java est offert par Oracle, actuellement la plupart des entreprises préfèrent embaucher des personnes qui ont une certification. Une certification Java prouve qu'une personne est compétent dans la technologie Java et possède les compétences requises définit nécessaires pour effectuer une tâche spécifique Avoir une certification permet d’ouvrir plusieurs opportunités à savoir : Cursus du développeur mobile ( Android ) Cursus du développeur web ( JEE , Spring framework ..) Cursus développeur Java Desktop Application En plus == > Avoir la certification, ça implique la maitrise du concept de l’orienté objet  Python, Php, Ruby, Objective C, Swift, …
  • 3. Formation OCA Java Se 8 Programmer (1Z0-808) Présentation générale Formation OCA Java Se 8 Programmer I 1Z0-808
  • 4. Formation OCA Java Se 8 Programmer (1Z0-808) Présentation formateur Anis Hachani Contact : contact@ghazelatc.com Mon profil LinkedIn : https://www.linkedin.com/in/anis-hachani-546bb13a/ Formateur ,Chef de projet et consultant en IT Fondateur de Ghazela Technology Academy : Formation et consulting en Technology, Management et en Digital Sous-traitance de projets informatique Je dispense des formations en IT depuis plus de 6 ans.
  • 5. Formation OCA Java Se 8 Programmer (1Z0-808) Plan formation Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) Java Building Blocks Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) Operators and Statments Chapitre 3 : Librairie native de java, (API Java ) Core Java APIs Chapitre 4 : Méthode et encapsulation Methodes and Encapsultion Chapitre 5 : Héritage, Polymorphisme , Interface, classes abstraites Class Design Chapitre 6 : Les Exceptions, les classe imbriquées, les classes anonymes, Lambda Exceptions, Inner class, Anonymous class, Lambda
  • 6. Formation OCA Java Se 8 Programmer (1Z0-808) Prérequis Avoir suivi la formation Programmation Orientée Objet en Java ou avoir les connaissances équivalentes Avoir une bonne pratique du langage Java sur au moins un projet.
  • 7. Formation OCA Java Se 8 Programmer (1Z0-808) Public concerné Développeur Java Chef de projet Développeur ayant codé avec un autre langage de programmation orienté objet
  • 8. Formation OCA Java Se 8 Programmer (1Z0-808) Objectifs visés Réussir la certification " Oracle Certified Associate, Java SE 8 Programmer I ,OCJA 8 , 1Z0-808
  • 9. Formation OCA Java Se 8 Programmer (1Z0-808) Environnement de travail Machine : Windows XP/7/8/8.1/10.. | Linux ou Unix Outils : Bloc note , note pad ++ IDE : Netbeans | Eclipse| autre IDE Programme à télécharger : JDK 1.8
  • 10. Formation OCA Java Se 8 Programmer (1Z0-808) Liens des ressources logicielles Note pad ++ : https://notepad-plus-plus.org/download/v7.3.3.html Netbeans : https://netbeans.org/downloads/ JDK 1.8 : http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads- 2133151.html Lien dans le site officiel : https://education.oracle.com/pls/web_prod-plq- dad/db_pages.getpage?page_id=5001&get_params=p_exam_id:1Z0-808
  • 11. Formation OCA Java Se 8 Programmer (1Z0-808) Aperçu sur l’examen OCJA – 1Z0-808 La langue de l’examen est aux choix : Français, Anglais … Lien dans le site officiel : https://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=5001&get_params=p_exam_id:1Z0-808
  • 12. Formation OCA Java Se 8 Programmer (1Z0-808) Support de cours
  • 13. Formation OCA Java Se 8 Programmer (1Z0-808) 13 Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 14. Formation OCA Java Se 8 Programmer (1Z0-808) 14 Révision : Généralités… • Un peu plus qu’un langage de programmation: • “gratuit”! • Indépendant de la plateforme • Langage interprété et byte code • Portable • Syntaxe à la C • Orienté objet (classes héritage) • Nombreuses bibliothèques • Pas de pointeurs! (ou que des pointeurs!) • Ramasse-miettes Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 15. Formation OCA Java Se 8 Programmer (1Z0-808) 15 Plateforme Java • La compilation génère un .class en bytecode (langage intermédiaire indépendant de la plateforme). • Le bytecode est interprété par un interpréteur Java JVM • Java Virtual Machine Compilation javac interprétation java Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 16. Formation OCA Java Se 8 Programmer (1Z0-808) 16 • Indépendance de la plateforme Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 17. Formation OCA Java Se 8 Programmer (1Z0-808) 17 Plateforme Java : plateforme indépendant de l’OS • La plateforme java: software au-dessus d’une plateforme exécutable sur un hardware (exemple MacOs, linux …) • Java VM • Java application Programming Interface (Java API): Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 18. Formation OCA Java Se 8 Programmer (1Z0-808) 18 Java ,tout un environnement… • JDK: Java Developpement Kit • JRE : Java Runtime Environment • Java compiler,Java Debugger • RMI ,Awt , Swing, Internal and external API(Application programmable interface ) • IDE ( eclipse ,Netbeans, jdeveloper ) Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 19. Formation OCA Java Se 8 Programmer (1Z0-808) 19 Utilisation du langage Java pour développer: • Une application avec interface graphique • Une application Android • Java Enterprise Edition JEE6,7,8..,etc.. Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 20. Formation OCA Java Se 8 Programmer (1Z0-808) 1- Téléchargement et installation du JDK 1.8 2- Configuration de la variable d'environnement JAVA_HOME 3- Compilation et exécution d’une class java 4- Téléchargement Installation Netbeans Exercice Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 21. Formation OCA Java Se 8 Programmer (1Z0-808) test.java 1 - Créer le fichier test.java sous c:/java 2 – Compiler en byte code le fichier test.java avec la commande Javac javac test.java 3 – java test public class test { /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("hello"); } } Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 22. Formation OCA Java Se 8 Programmer (1Z0-808) Principes de base de la Programmation orientée objet Classe : Représente le modèle Une classe a des champs nommé attribut Une classe a des fonction appelé méthodes L’appel d’une classe est appelé instanciation ,le résultat de Cet appel est appelé un objet Exemple: Voiture a un vitesse x , un prix y, un modèle z La voiture roule: ( action) Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 23. Formation OCA Java Se 8 Programmer (1Z0-808) Implémentation de la classe voiture Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 24. Formation OCA Java Se 8 Programmer (1Z0-808) Les identifiants légaux ( Legal Identifiers ) 1 . Identifiers must start with a letter, a currency character ($), or a Connecting character such as the underscore ( _ ). Identifiers cannot start with a number! After the first character, identifiers can contain any combination of letters, currency characters, connecting characters, or numbers. Enum Identifiers in Java are case-sensitive; foo and COLLIE ,collie are two different identifiers. Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 25. Formation OCA Java Se 8 Programmer (1Z0-808) On ne peut pas utiliser le mot Java comme identifiant an identifier. Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 26. Formation OCA Java Se 8 Programmer (1Z0-808) General code best practice ( Les bonnes pratique de coding en Java ) Classes and interfaces The first letter should be capitalized: Example for classes: Dog Account PrintWriter Example for interfaces : Runnable Serializable Example for methodes : getBalance get/set/is doCalculation setCustomerName Variables (miniscule): buttonWidth accountBalance Constants (majuscule) ex :static, final : MIN_HEIGHT Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 27. Formation OCA Java Se 8 Programmer (1Z0-808) Une seule classe public dans un fichier .java 1 - There can be only one public class per source code file. 2 - A file can have more than one nonpublic class. Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 28. Formation OCA Java Se 8 Programmer (1Z0-808) Access modifiers ( Les Modificateurs d'accès ) class MyClass { } Access modifiers: public, protected, private, package (par défaut ) Variable , méthode & classe Class : Public : La classe est accessible pour toute les classes du projet Package: La classe est accessible par toute les classes du même package Protected /private pas de sens Ordre de visibilité : Classe, méthode, variable Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 29. Formation OCA Java Se 8 Programmer (1Z0-808) Visibilité Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 30. Formation OCA Java Se 8 Programmer (1Z0-808) Visibilité Private < package < Protected < Public Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 31. Formation OCA Java Se 8 Programmer (1Z0-808) If there is a public class in a file, the name of the file must match the name of the public class. For example, a class declared as public class Dog { } must be in a source code file named Dog.java. Les bonnes pratiques de coding ( Coding est practice ) Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 32. Formation OCA Java Se 8 Programmer (1Z0-808) Import de la classe Beverage Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 33. Formation OCA Java Se 8 Programmer (1Z0-808) Commentaire // Comments // comment until end of line /* Multiple * line comment */ Raccourcit : ctrl + alt+ c Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 34. Formation OCA Java Se 8 Programmer (1Z0-808) Import des classes // Class imports Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 35. Formation OCA Java Se 8 Programmer (1Z0-808) import des classes // Concept package : Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 36. Formation OCA Java Se 8 Programmer (1Z0-808) Concept package : import des classes Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 37. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 38. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 39. Formation OCA Java Se 8 Programmer (1Z0-808) Constructor Declarations ( la déclaration des contructeurs ) In Java, objects are constructed. Every time you make a new object, at least one constructor is invoked. Every class has a constructor, although if you don't create one explicitly, the compiler will build one for you. There are tons of rules concerning Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 40. Formation OCA Java Se 8 Programmer (1Z0-808) Block d’initialisation // Instance Initializer Blocks Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 41. Formation OCA Java Se 8 Programmer (1Z0-808) Lab : initialization bloc (Block d’initialisation ) Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 42. Formation OCA Java Se 8 Programmer (1Z0-808) Lab : initialization bloc Resultat : 5 Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 43. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 44. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 45. Formation OCA Java Se 8 Programmer (1Z0-808) Les identifiants / / Identifiers Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 46. Formation OCA Java Se 8 Programmer (1Z0-808) Apprendre les valeurs par défaut des variables Understanding Default Initialization of Variables Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 47. Formation OCA Java Se 8 Programmer (1Z0-808) Le scope de la variable // Variables scope Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 48. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 49. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 50. Formation OCA Java Se 8 Programmer (1Z0-808) Le ramasse miette // Garbage Collection Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 51. Formation OCA Java Se 8 Programmer (1Z0-808) Remember, finalize() is only run when the object is eligible for garbage collection. Chapitre 1 : Initiation orienté objet (class, objet, instance, variable ..) ~ Java Building Blocks
  • 52. Formation OCA Java Se 8 Programmer (1Z0-808) Exercice du premier chapitre Chapter 1 questions Chapitre 1 : Java Building Blocks
  • 53. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 1 : Java Building Blocks
  • 54. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 1 : Java Building Blocks
  • 55. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 1 : Java Building Blocks
  • 56. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 1 : Java Building Blocks
  • 57. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 1 : Java Building Blocks Liste des exercices Page 42 OCA Oracle Certified Associate Java SE 8 Programmer I Study Guide Exam 1Z0-808
  • 58. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 59. Formation OCA Java Se 8 Programmer (1Z0-808) Default litervals for int, long ,float , double Les valeurs par défault pour int, long , float, double byte < short < int < long : entier float < double : réel Toute valeur entier est considéré comme un int Toute valeur réel est considéré comme un double Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 60. Formation OCA Java Se 8 Programmer (1Z0-808) Comprendre les operateurs java Understanding Java Operators int y = 4; double x = 3 + 2 * --y; Result of x Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 61. Formation OCA Java Se 8 Programmer (1Z0-808) Comprendre les operateurs java Understanding Java Operators Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 62. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments Comprendre les operateurs java Understanding Java Operators
  • 63. Formation OCA Java Se 8 Programmer (1Z0-808) Arithmetic Operators Les operateurs arithmétique int x = 2 * 5 + 3 * 4 - 8; Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 64. Formation OCA Java Se 8 Programmer (1Z0-808) Arithmetic operators are often encountered in early mathematics and include addition (+), subtraction (-), multiplication (*), division (/), and modulus (%). They also include the As you may have noticed in Table 2.1, the multiplicative operators (*, /, %) have a higher order of precedence than the additive operators (+, -). That means when you see an expression such as this: int x = 2 * 5 + 3 * 4 - 8; You first evaluate the 2 * 5 and 3 * 4, which reduces the expression to the following: int x = 10 + 12 - 8; Then, you evaluate the remaining terms in left-to-right order, resulting in a value of x of 14. Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments Arithmetic Operators Les operateurs arithmétique
  • 65. Formation OCA Java Se 8 Programmer (1Z0-808) int x = 2 * ((5 + 3) * 4 – 8); Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 66. Formation OCA Java Se 8 Programmer (1Z0-808) Notice that we said “Unless overridden with parentheses…”. That’s because you can change the order of operation explicitly by wrapping parentheses around the sections you want evaluated first. Compare the previous example with the following one containing the same values and operators, in the same order, but with two sets of parentheses: int x = 2 * ((5 + 3) * 4 – 8); This time you would evaluate the addition operator 10 + 3, which reduces the expression to the following: int x = 2 * (8 * 4 – 8); You can further reduce this expression by multiplying the first two values within the parentheses: int x = 2 * (32 – 8); Next, you subtract the values within the parentheses before applying terms outside the parentheses: int x = 2 * 24; Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 67. Formation OCA Java Se 8 Programmer (1Z0-808) System.out.print(9 / 3); System.out.print(9 % 3); Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 68. Formation OCA Java Se 8 Programmer (1Z0-808) Numeric Promotion Rules ( Règles de promotion numérique ) 1. If two values have different data types, Java will automatically promote one of the values to the larger of the two data types Si on a deux valeurs de type de donnée différent, java va automatiquement adapter un des deux valeurs vers le type de donnée le plus large. . 2. If one of the values is integral and the other is floating-point, Java will automatically promote the integral value to the floating- point value’s data type. Si on deux valeurs, le premier est de type entier, le deuxième est de type réel , Java va adapter automatiquement la valeur de type entier en une valeur de type réel 3. Smaller data types, namely byte, short, and char, are first promoted to int any time they’re used with a Java binary arithmetic operator, even if neither of the operands is int. Les données les plus petit à savoir byte, short, and char, vont etre adapter avec les opérations arithmétique vers le type de donnée entier meme si aucun des deux valeurs est de type entier 4. After all promotion has occurred and the operands have the same data type, the resulting value will have the same data type as its promoted operands. - Le type de donnée de la valeur du résultat va s’adapter au des deux type de donnée de l’opération Chapitre 2 : Operators and Statements
  • 69. Formation OCA Java Se 8 Programmer (1Z0-808) What is the data type of x * y? int x = 1; long y = 33; What is the data type of x + y? double x = 39.21; float y = 2.1; Numeric Promotion Rules Règles de promotion numérique Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 70. Formation OCA Java Se 8 Programmer (1Z0-808) What is the data type of x * y? int x = 1; long y = 33; If we follow the first rule, since one of the values is long and the other is int, and long is larger than int, then the int value is promoted to a long, and the resulting value is long. What is the data type of x + y? double x = 39.21; float y = 2.1; This is actually a trick question, as this code will not compile! As you may remember from Chapter 1, floating-point literals are assumed to be double, unless post fixed with an f, as in 2.1f. If the value was set properly to 2.1f, then the promotion would be similar to the last example, with both operands being promoted to a double, and the result would be a double value. Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 71. Formation OCA Java Se 8 Programmer (1Z0-808) What is the data type of x / y? short x = 10; short y = 3; What is the data type of x * y / z? short x = 14; float y = 13; double z = 30; Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 72. Formation OCA Java Se 8 Programmer (1Z0-808) What is the data type of x / y? short x = 10; short y = 3; In this case, we must apply the third rule, namely that x and y will both be promoted to int before the operation, resulting in an output of type int. Pay close attention to the fact that the resulting output is not a short, as we’ll come back to this example in the upcoming section on assignment operators. ¦ What is the data type of x * y / z? short x = 14; float y = 13; double z = 30; In this case, we must apply all of the rules. First, x will automatically be promoted to int solely because it is a short and it is being used in an arithmetic binary operation. The promoted x value will then be automatically promoted to a float so that it can be multiplied with y. The result of x * y will then be automatically promoted to a double, so that it can be multiplied with z, resulting in a double value. Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 73. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments Les opérateurs unaire
  • 74. Formation OCA Java Se 8 Programmer (1Z0-808) The logical complement operator ! ( l’opérateur logique complémentaire ! ) boolean x = false; System.out.println(x); x = !x; System.out.println(x); Likewise, the negation operator, -, reverses the sign of a numeric expression, as shown in these statements: System.out.println(x); // 1.21 x = -x; System.out.println(x); // -1.21 x = -x; System.out.println(x); // 1.21 Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 75. Formation OCA Java Se 8 Programmer (1Z0-808) int x = !5; boolean y = -true boolean z = !0; Will this run ? Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 76. Formation OCA Java Se 8 Programmer (1Z0-808) The following code snippet illustrates this distinction: int counter = 0; System.out.println(counter); // Outputs 0 System.out.println(++counter); // Outputs 1 System.out.println(counter); // Outputs 1 System.out.println(counter--); // Outputs 1 System.out.println(counter); // Outputs 0 The first pre-increment operator updates the value for counter and outputs the new value of 1. The next post-decrement operator also updates the value of counter but outputs the value before the decrement occurs. One common practice in a certification exam, is to apply multiple increment or decrement operators to a single variable on the same line: int x = 3; int y = ++x * 5 / x-- + --x; System.out.println("x is " + x); System.out.println("y is " + y); Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments Increment and Decrement Operators Les opérateurs d’incrementation et de décrementation
  • 77. Formation OCA Java Se 8 Programmer (1Z0-808) Increment and Decrement Operators Les opérateurs d’incrémentation et de décrémentation int x = 3; int y = ++x * 5 / x-- + --x; System.out.println("x is " + x); System.out.println("y is " + y); So how do you read this code? First, the x is incremented and returned to the expression, which is multiplied by 5. We can simplify this: int y = 4 * 5 / x-- + --x; // x assigned value of 4 Next, x is decremented, but the original value of 4 is used in the expression, leading to this: int y = 4 * 5 / 4 + --x; // x assigned value of 3 The assignment of x reduces the value to 2, and since this is a pre-increment operator, that value is returned to the expression: int y = 4 * 5 / 4 + 2; // x assigned value of 2 Finally, we evaluate the multiple and division from left-to-right, and finish with the addition. The result is then printed: x is 2 y is 7 Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 78. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments Increment and Decrement Operators Les opérateurs d’incrementation et de décrementation Int x = 5 System.out.println( ++x + x + x++ + x + x + x++ );
  • 79. Formation OCA Java Se 8 Programmer (1Z0-808) Increment and Decrement Operators Les opérateurs d’incrementation et de décrementation Int x = 5 ++ x : pre-incrementation ( pre-increment operator ) : L’operateur d’incrementation est appliqué et la nouvelle valeur de x est mis à jour x++ : post-incrementation ( post-increment operator ): La valeur d’origine de x est affichée et l’operateur d’incrementation est appliqué au prochain traitement ou affichage . Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 80. Formation OCA Java Se 8 Programmer (1Z0-808) Les operateurs d’affectation (Assignment Operators ) Chapitre 2 : Operators and Statements
  • 81. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments Casting des types primitive
  • 82. Formation OCA Java Se 8 Programmer (1Z0-808) short x = 10; short y = 3; short z = x * y; Will this compile Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 83. Formation OCA Java Se 8 Programmer (1Z0-808) short x = 10; short y = 3; short z = (short)(x * y); short values are automatically promoted to int when applying any arithmetic operator, with the resulting value being of type int. Trying to set a short variable to an int results in a compiler error, as Java thinks you are trying to implicitly convert from a larger data type to a smaller one. Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 84. Formation OCA Java Se 8 Programmer (1Z0-808) Compound Assignment Operators ( Les opérateurs d’affectation composées ) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 85. Formation OCA Java Se 8 Programmer (1Z0-808) Relational Operators ( les opérateurs relationnel ) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 86. Formation OCA Java Se 8 Programmer (1Z0-808) Logical Operators (Les opérateurs logiques) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 87. Formation OCA Java Se 8 Programmer (1Z0-808) Logical operators Les opérateurs logique Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 88. Formation OCA Java Se 8 Programmer (1Z0-808) int x = 6; boolean y = (x >= 6) || (++x <= 7); System.out.println(x); Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments Logical operators Les opérateurs logique
  • 89. Formation OCA Java Se 8 Programmer (1Z0-808) int x = 6; boolean y = (x >= 6) || (++x <= 7); System.out.println(x); Because x >= 6 is true, the increment operator on the right-hand side of the expression is never evaluated, so the output is 6. Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments Logical operators Les opérateurs logique
  • 90. Formation OCA Java Se 8 Programmer (1Z0-808) Equality Operators ( Opérateurs d'égalité ) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 91. Formation OCA Java Se 8 Programmer (1Z0-808) Understanding Java Statements Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 92. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 93. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 94. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments Ternary Operator Opérateur Ternaire
  • 95. Formation OCA Java Se 8 Programmer (1Z0-808) int y = 1; int z = 1; final int x = y<10 ? y++ : z++; System.out.println(y+","+z); Chapitre 2 : Operators and Statements Ternary Operator Opérateur Ternaire
  • 96. Formation OCA Java Se 8 Programmer (1Z0-808) int y = 1; int z = 1; final int x = y<10 ? y++ : z++; System.out.println(y+","+z); // Outputs 2,1 Notice that since the left-hand boolean expression was true, only y was incremented. Contrast the preceding example with the following modifi cation Chapitre 2 : Operators and Statements Ternary Operator Opérateur Ternaire
  • 97. Formation OCA Java Se 8 Programmer (1Z0-808) int y = 1; int z = 1; final int x = y>=10 ? y++ : z++; System.out.println(y+","+z); Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments Ternary Operator Opérateur Ternaire
  • 98. Formation OCA Java Se 8 Programmer (1Z0-808) int y = 1; int z = 1; final int x = y>=10 ? y++ : z++; System.out.println(y+","+z); // Outputs 1,2 Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments Ternary Operator Opérateur Ternaire
  • 99. Formation OCA Java Se 8 Programmer (1Z0-808) Switch case Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 100. Formation OCA Java Se 8 Programmer (1Z0-808) 100 While and do • while • ++ expression of a while loop must be declared before the expression is evaluated  illegal: while (boolean x = true) {} • The expression result must be a boolean • do Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 101. Formation OCA Java Se 8 Programmer (1Z0-808) 101 While int x = 2; int y = 5; while(x < 10) y++; ? Boucle infinie Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 102. Formation OCA Java Se 8 Programmer (1Z0-808) 102 Do , While int x = 0; do { x++; } while(false); System.out.println(x); Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 103. Formation OCA Java Se 8 Programmer (1Z0-808) 103 Do , While int x = 0; do { x++; } while(false); System.out.println(x); // Outputs 1 Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 104. Formation OCA Java Se 8 Programmer (1Z0-808) 104 Do , While Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 105. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 106. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 107. Formation OCA Java Se 8 Programmer (1Z0-808) Will this compile for(int i = 0; i < 10; i++) { System.out.print(i + " "); } Will this compile for( ; ; ) { System.out.println("Hello World"); } ? Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 108. Formation OCA Java Se 8 Programmer (1Z0-808) Adding Multiple Terms to the for Statement int x = 0; for( long y = 0, z = 4; x < 5 && y < 10; x++, y++) { System.out.print(y + " "); } System.out.print(x); Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 109. Formation OCA Java Se 8 Programmer (1Z0-808) int x = 0; for(long y = 0, x = 4; x < 5 && y < 10; x++, y++) { System.out.print(x + " "); } What do you think Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 110. Formation OCA Java Se 8 Programmer (1Z0-808) We can fix this loop by changing the declaration of x and y as follows: int x = 0; long y = 10; for(y = 0, x = 4; x < 5 && y < 10; x++, y++) { System.out.print(x + " "); } Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 111. Formation OCA Java Se 8 Programmer (1Z0-808) for(long y = 0, int x = 4; x < 5 && y<10; x++, y++) { System.out.print(x + " "); } What do yo think ? Declaring long y and int x Déclaration de long y et de int x Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 112. Formation OCA Java Se 8 Programmer (1Z0-808) Using Loop Variables Outside the Loop Utlisation d’une variable déclaré dans une boucle à l’exterieur du boucle for(long y = 0, x = 4; x < 5 && y < 10; x++, y++) { System.out.print(y + " "); } System.out.print(x); What do you think Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 113. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Operators and Statements Enhanced loop ~ boucle for amélioré
  • 114. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Operators and Statements
  • 115. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Operators and Statements Enhanced loop ~ boucle for amélioré
  • 116. Formation OCA Java Se 8 Programmer (1Z0-808) Nested Loops ( les boucles imbriquées ) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 117. Formation OCA Java Se 8 Programmer (1Z0-808) Nested loops can include while and do-while, as shown in this example. See if you can determine what this code will output. int x = 20; while(x>0) { do { x -= 2 } while (x>5); x--; System.out.print(x+"t"); } Nested Loops ( les boucles imbriquées ) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 118. Formation OCA Java Se 8 Programmer (1Z0-808) Optional labels ( les labels optionnelles ) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 119. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments break statement transfers the fow of control out to the enclosing statement , Break with a label break transfer le control de flux à l’extérieur du bloc d’instruction actuel , Break avec un label
  • 120. Formation OCA Java Se 8 Programmer (1Z0-808) Optional labels ( les labels optionnelles ) break statement transfers the fow of control out to the enclosing statement , Break with a label break transfer le control de flux à l’extérieur du bloc d’instruction actuel , Break avec un label Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 121. Formation OCA Java Se 8 Programmer (1Z0-808) Let’s now complete our discussion of advanced loop control with the continue statement, astatement that causes how to finish the execution of the current loop ( current interation ), Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 122. Formation OCA Java Se 8 Programmer (1Z0-808) break permet de transférer le control à l'extérieur du bloc d’intruction actuel, continue permet de d’arreter le traitement actuel and passer à la prochaine intération Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 123. Formation OCA Java Se 8 Programmer (1Z0-808) continue with a label continue without a label continue avec un label continues sans label Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 124. Formation OCA Java Se 8 Programmer (1Z0-808) break with a label Break avec un label Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 125. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 126. Formation OCA Java Se 8 Programmer (1Z0-808) Exam questions Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 127. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 128. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 129. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 130. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 131. Formation OCA Java Se 8 Programmer (1Z0-808) Liste des exercices Page 94 OCA Oracle Certified Associate Java SE 8 Programmer I Study Guide Exam 1Z0-808 Chapitre 2 : Opérateurs et structures conditionnelles ( > =, if, else) ~ Operators and Statments
  • 132. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 133. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 134. Formation OCA Java Se 8 Programmer (1Z0-808) What’s the output int three = 3; String four = "4"; System.out.println(1 + 2 + three + four); Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 135. Formation OCA Java Se 8 Programmer (1Z0-808) ++ Strings Are Immutable Objects Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Once a String object is created, it is not allowed to change. It cannot be made larger or smaller, and you cannot change one of the characters inside it. Le moment ou l’objet string est crée, il est pas possible de le changer. Apercu sur la mémoire
  • 136. Formation OCA Java Se 8 Programmer (1Z0-808) ++ Strings Are Immutable Objects String name = "Fluffy"; name = "anis"; System.out.println(name); What’s the output Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 137. Formation OCA Java Se 8 Programmer (1Z0-808) ++ Strings Are Immutable Objects String name = "Fluffy"; name = "anis"; System.out.println(name); == > String name = "Fluffy"; name = new String(" anis ") System.out.println(name); Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 138. Formation OCA Java Se 8 Programmer (1Z0-808) String Class methodes – page 105 Les méthodes de la classe String Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 139. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 140. Formation OCA Java Se 8 Programmer (1Z0-808) Which one compiles ? Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 141. Formation OCA Java Se 8 Programmer (1Z0-808) String Object is length() For tables it is length Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 142. Formation OCA Java Se 8 Programmer (1Z0-808) The StringBuffer and StringBuilder Classes The java.lang.StringBuffer and java.lang.StringBuilder classes should be used when you have to make a lot of modifications to strings of characters As we discussed in the previous section, String objects are immutable, so if you choose to do a lot of manipulations with String objects, you will end up with a lot of abandoned String objects in the String pool (waste precious memory ) objects of type StringBuffer and StringBuilder can be modified over and over again without leaving behind a great effluence of discarded String objects Oracle recommends that you use StringBuilder instead of StringBuffer whenever possible because StringBuilder will run faster (and perhaps jump higher). anything we say about StringBuilder's methods holds true for StringBuffer's methods . Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 143. Formation OCA Java Se 8 Programmer (1Z0-808) We got a nice new String out of the deal, but the downside is that the old String abc" has been lost in the String pool, thus wasting memory. If we were using a StringBuffer instead of a String, the code would look like this: Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 144. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 145. Formation OCA Java Se 8 Programmer (1Z0-808) Example of some methodes of the StringBuilder Classes - Page 114 Exemple des méthodes de la classe StringBuilder - Page 114 Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 146. Formation OCA Java Se 8 Programmer (1Z0-808) Understanding Equality Comprendre l’égalité Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 147. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Understanding Equality ( with reference or with equals methode Comprendre l’égalité ( avec la référence ou par la méthode equals )
  • 148. Formation OCA Java Se 8 Programmer (1Z0-808) Understanding Java Arrays Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 149. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 150. Formation OCA Java Se 8 Programmer (1Z0-808) int[] numbers2 = {42, 55, 99}; Finally, you can type the [] before or after the name, and adding a space is optional. This means that all four of these statements do the exact same thing: int[] numAnimals; int [] numAnimals2; int numAnimals3[]; int numAnimals4 []; Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 151. Formation OCA Java Se 8 Programmer (1Z0-808) Array Declarations ~ déclaration d’un tableau In Java, arrays are objects that store multiple variables of the same type, or variables that are all subclasses of the same type. Arrays can hold either primitives or object We can also declare multidimensional arrays, which are in fact arrays of arrays. This can be done in the following manner: String[][][] occupantName; String[] managerName []; Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 152. Formation OCA Java Se 8 Programmer (1Z0-808) Exemple, pour allouer une matrice de 5 lignes de 6 colonnes Int [ ] [ ] matrice = new int [5] [6] Une autre manière : int[][] matrice = { { 0, 1, 4, 3 } , // tableau [0] de int { 5, 7, 9, 11, 13, 15, 17 } // tableau [1] de int }; int i, j; for(i=0; i<matrice.length; i++) { for(j=0; j<matrice[i].length; j++) { //Action sur matrice[i][j] } } Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Array Declarations ~ déclaration d’un tableau
  • 153. Formation OCA Java Se 8 Programmer (1Z0-808) 153 • Public String toString() • Returns a "text representation" of the object. • Can override to explain the class. • void finalize() • Called by garbage collector when the garbage collector sees that the object cannot be referenced. • final void notify() • Wakes up a thread that is waiting for this object's lock. • final void notifyAll () • Wakes up all threads that are waiting for this object's lock. • final void wait() • Pauses the current thread to wait until another thread calls notify() or notifyAll() on this subject. Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Object class methods ~ les méthodes de la class Object
  • 154. Formation OCA Java Se 8 Programmer (1Z0-808) when we don’t override toString ~ lorsque qu’on redéfinit pas la méthode ToString() Hashcode : objectid Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 155. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs when we override toString ~ lorsqu’on redéfinit pas la méthode ToString()
  • 156. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 157. Formation OCA Java Se 8 Programmer (1Z0-808) What about this ? String[] birds = new String[6]; System.out.println(birds.length); Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Using an Array ~ utilisation d’un tableau
  • 158. Formation OCA Java Se 8 Programmer (1Z0-808) Sorting ~ le Tri import java.util.* // import whole package including Arrays import java.util.Arrays; // import just Arrays The result is ? Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 159. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 160. Formation OCA Java Se 8 Programmer (1Z0-808) Trying this again with String types // Essaie du tri avec les types String : String[] strings = { "10", "9", "100" }; Arrays.sort(strings); for (String string : strings) System.out.print(string + " "); What’s the output Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Theproblem is that String sorts in alphabetic order, and 1 sorts before 9. (Numbers sort before letters and uppercase sorts before lowercase, in case you were wondering.)
  • 161. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Creating a multidimensionnal Array // creation d’un tableau à deux dimension
  • 162. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Searching // la recherche
  • 163. Formation OCA Java Se 8 Programmer (1Z0-808) Varagrs // argument variable Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 164. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Methods with variable argument Lists ( vars-args) Méthodes avec des arguments variable ( vars-args
  • 165. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Methods with variable argument Lists ( vars-args) Méthodes avec des arguments variable ( vars-args
  • 166. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 167. Formation OCA Java Se 8 Programmer (1Z0-808) Understanding an ArrayList Comprendre les ArrayList Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 168. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Creating an ArrayList La creation d’un ArrayList
  • 169. Formation OCA Java Se 8 Programmer (1Z0-808) the new and improved way. Java 5 introduced generics, which allow you to specify the type of class that the ArrayList will contain. Java 5 a introduit les generics qui vont permettre de spécifier le type de donnée d’une liste ArrayList <String> list4 = new ArrayList<String>(); ArrayList <String> list5 = new ArrayList<>(); Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 170. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 171. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Add method // la méthode Add
  • 172. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs remove method // la méthode remove
  • 173. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs set method // la méthode set
  • 174. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs isEmpty() and size() method // la méthode Add isEmpty() et size()
  • 175. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs clear method // la méthode clear
  • 176. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs contains method // la méthode contains
  • 177. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs equals method // la méthode equals
  • 178. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Converting between array and List La conversion entre un tableau ( array) et une liste
  • 179. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Sorting // le tri
  • 180. Formation OCA Java Se 8 Programmer (1Z0-808) The wrapper classes in the Java API serve two primary purposes: Up to now, we’ve only put String objects in the ArrayList. What happens if we want to put primitives in? Each primitive type has a wrapper class, which is an object type that There is a wrapper class for every primitive in Java. For instance, the wrapper class for int is Integer, the class for float is Float, and so on. Remember that the primitive name is simply the lowercase name of the wrapper except for char, which maps to Character, and int, which maps to Integer. Table 3-2 lists the wrapper classes in the Java API. Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 181. Formation OCA Java Se 8 Programmer (1Z0-808) 1 Overview // Apercu • boolean | Boolean | boolean or String • byte | Byte | byte or String • char | Character | char • double | Double | double or String • float | Float | float, double, or String • short | Short | short or String • int | Integer | int or String • long | Long | long or String • Wrapper objects are immutable, as String, value can’t change Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 182. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Declaration of a Wrapper Object La déclaration d’un Wrapper Object
  • 183. Formation OCA Java Se 8 Programmer (1Z0-808) 183 When you need to convert the value of a wrapped numeric to a primitive, use one of the many xxxValue() methods  primitive xxxValue() ◦ to convert a Wrapper to a primitive: int x = xxWrapper.intValue(); Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Wrapper Conversion Utilities les outils de conversion des Wrapper class
  • 184. Formation OCA Java Se 8 Programmer (1Z0-808) 184 Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Declaration of a Wrapper Object La déclaration d’un Wrapper Object
  • 185. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 186. Formation OCA Java Se 8 Programmer (1Z0-808) Wrapper coversion table ,page 243 Table de conversion des Wrapper Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 187. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 188. Formation OCA Java Se 8 Programmer (1Z0-808) Wrapper are immutable Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 189. Formation OCA Java Se 8 Programmer (1Z0-808) Y++ Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 190. Formation OCA Java Se 8 Programmer (1Z0-808) The API developers decided that for all the wrapper classes, two objects are equal if they are of the same type and have the same value. It shouldn't be surprising that == check if the object is same, equals() check the value Autoboxing Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 191. Formation OCA Java Se 8 Programmer (1Z0-808) == check if the object is same, equals() check the value Autoboxing Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 192. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 193. Formation OCA Java Se 8 Programmer (1Z0-808) Example of Boxing Exemple d’utilisation du Boxing Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 194. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Conversion between Array and List Conversion entre Arrays et List
  • 195. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Conversion between Array and List Conversion entre Arrays et List
  • 196. Formation OCA Java Se 8 Programmer (1Z0-808) Working with Dates and Times Utilisaiton du Dates et Times Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs
  • 197. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Working with Dates and Times Utilisaiton du Dates et Times
  • 198. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Working with Dates and Times Utilisaiton du Dates et Times
  • 199. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Manipulation Dates and Times Utilisation du Dates et Times
  • 200. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Manipulation Dates and Times Utilisation du Dates et Times
  • 201. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Manipulation Dates and Times Utilisation du Dates et Times
  • 202. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Working with Periods Utilisation des Periode
  • 203. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Working with Periods Utilisation des Periode
  • 204. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Formatting Date and Time Personnalisé la date et le temp
  • 205. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Formatting Date and Time Personnalisé la date et le temp
  • 206. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Formatting Date and Time Personnalisé la date et le temp
  • 207. Formation OCA Java Se 8 Programmer (1Z0-808) Chapitre 3 : Librairie native de java, (API Java ) ~ Core Java APIs Parsing Date and Time Parcourir la date et le temp