Attribuer et afficher (print)
Après avoir déclaré les variables, vous leur attribuez des valeurs à l'aide de l'opérateur =. Une fois attribuées, vous pouvez afficher les valeurs à l'aide de System.out.println().
Veuillez essayer.
Cet exercice fait partie du cours
Introduction à Java
Instructions
- Créez une variable
Stringcreatoret attribuez-lui la valeur"James Gosling". - Affichez la variable
creator.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
class InfoAboutJava {
public static void main(String[] args) {
String language = "Java";
int yearOfOrigin = 1995;
// Create and assign the creator variable
String ____ ____ ____;
System.out.println(language);
System.out.println(yearOfOrigin);
// Print the creator of Java
System.out.println(____);
}
}