Strings, chars, and booleans
Beyond numbers, Java offers data types for text, individual characters, and true/false values. Each serves a unique purpose in representing different kinds of information. Let's practice working with these essential types!
Deze oefening maakt deel uit van de cursus
Introduction to Java
Oefeninstructies
- Declare the
tshirtSizevariable using the correct primitive type. - Assign
trueto theisOnSalevariable. - Declare
Stringvariable calledcolor, setting its value to"green".
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
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 = ____;
}
}