Using a Variable

After declaring and assigning the variable, you only need to use the variable name. Place the name where you will use it instead of a value and before the end of the line.

Examples:

Processing and Java-based example:

String name = "Chuck";

println("Your name is " + name + "! Hello, " + name + ".");

// The above line would print "Your name is Chuck! Hello, Chuck."

C# example:

string name = "Chuck";

print("Your name is " + name + "! Hello, " + name + ".");

// The above line would print "Your name is Chuck! Hello, Chuck."

Python example:

name = "Chuck"
print("Your name is " + name + "! Hello, " + name + ".")

# The above line would print "Your name is Chuck! Hello, Chuck."

Last updated