Declare now, assign later
In Java, variables can be declared first and assigned a value later, giving your code flexibility. In this exercise, you'll declare a String variable and then assign it a list of ingredients. Let's get cooking! 🍫🥚🥛
Este ejercicio forma parte del curso
Introduction to Java
Instrucciones del ejercicio
- Declare a
String
variable calledingredients
without assigning it any value. - Assign
ingredients
the value of"chocolate, eggs, milk, flour, sugar, vanilla"
.
Ejercicio interactivo práctico
Prueba este ejercicio completando el código de muestra.
class DeclareThenAssign {
public static void main(String[] args) {
// Declare String variable called ingredients
____ ____;
// Assign ingredients value
____ = "chocolate, eggs, milk, flour, sugar, vanilla";
System.out.println(ingredients);
}
}