MulaiMulai sekarang secara gratis

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!

Latihan ini adalah bagian dari kursus

Introduction to Java

Lihat Kursus

Petunjuk latihan

  • Use String concatenation to add itemName to the first printout statement.
  • Add itemPrice to the second printout statement.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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 " ____ ____);
    }
}
Edit dan Jalankan Kode