String concatenation
Combining text is one of the most common operations in programming. Whether you're building personalized messages, creating reports, or formatting output, you'll use String concatenation constantly. Let's practice this essential skill!
Deze oefening maakt deel uit van de cursus
Introduction to Java
Oefeninstructies
- Use String concatenation to add
itemNameto the first printout statement. - Add
itemPriceto the second printout statement.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
class ConcatenateAway {
public static void main(String[] args) {
String itemName = "VR Headset";
int itemPrice = 599;
// Add itemName to the printout statement
System.out.println("Item is " + ____);
// Add itemPrice to the printout statement
System.out.println("Price is " ____ ____);
}
}