IniziaInizia gratis

Creating a variable

Variables are like labeled boxes where you store data in your programs. Every variable in Java needs a name and a type that tells Java what kind of data it will hold. Let's create your first variables!

Questo esercizio fa parte del corso

Introduction to Java

Visualizza il corso

Istruzioni dell'esercizio

  • Create a text variable called language that has the value of "Java".
  • Create a numerical variable called yearOfOrigin that is set to 1995.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

class InfoAboutJava {
	public static void main(String[] args) {
    	
        // Create a text variable called language
        String ____ = "Java";
        
        // Create a numerical variable called yearOfOrigin
        ____ ____ = 1995;

        System.out.println(language + " was created in " + yearOfOrigin);
    }
}
Modifica ed esegui il codice