Creating a variable
Before using a variable, you need to declare it by specifying its type and name. Java requires every variable to have a type that defines the kind of data it holds.
Cet exercice fait partie du cours
Introduction to Java
Instructions
- Create a
String
variable calledlanguage
that has the value of"Java"
. - Create a variable of type
int
calledyearOfOrigin
, that is set to1995
.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
class InfoAboutJava {
public static void main(String[] args) {
// Create a variable called language
String ____ = "Java";
// Create a variable called yearOfOrigin
____ ____ = 1995;
System.out.println(language + " was created in " + yearOfOrigin);
}
}