Strings, chars, and booleans
While the String data type is not a primitive, it is super important as well. It's time to practice them along with char and boolean.
This exercise is part of the course
Introduction to Java
Exercise instructions
- Declare the
tshirtSizevariable using the correct primitive type. - Assign
trueto theisOnSalevariable. - Declare
Stringvariable calledcolor, setting its value to"green".
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
class NumericalDeclarations {
public static void main(String[] args) {
// Declare the tshirt variable
____ tshirtSize = 'M';
// Assign true to isOnSale
boolean isOnSale = ____;
// Declare and assign color
____ color = ____;
}
}