String variables
A variable is a named place that holds a value. String message = scanner.nextLine(); in the last step created one. Variables can also get their value straight from the code:
String food = "pizza";
System.out.println(food);
System.out.println("food");
pizza
foodThe line String food = "pizza"; has three parts:
Stringis the variable's type: what kind of value it holds. AStringholds text.foodis the variable's name. You choose it.= "pizza"gives it its value.
After that, the name stands for the value. That's why System.out.println(food) prints pizza, while System.out.println("food"), with quotes, prints the word food itself. Quotes mean "this exact text"; no quotes mean "the value of this variable".
A variable has to be created before it's used, and Java checks the name's spelling and capitals: Food and food are two different names.