Challenge: Personalize Your Java Output

Let’s practice working with text (Strings) in Java.

Write a Java program that creates and prints a formatted message using strings, variables, and special characters.

Your task

  1. Create a String variable for your name.

  2. Create another String variable for a favorite activity.

  3. Print a message that:

    1. combines text and variables using +

    2. includes quotes around the activity

    3. prints the message across two lines

Example output (your text can vary)

Hello, my name is Alex.
I love "coding"!

Rules

  • Use String variables.

  • Use + to combine text and variables.

  • Use escape characters like \" or \n.

  • Write your code inside main.

Challenge: Personalize Your Java Output

Let’s practice working with text (Strings) in Java.

Write a Java program that creates and prints a formatted message using strings, variables, and special characters.

Your task

  1. Create a String variable for your name.

  2. Create another String variable for a favorite activity.

  3. Print a message that:

    1. combines text and variables using +

    2. includes quotes around the activity

    3. prints the message across two lines

Example output (your text can vary)

Hello, my name is Alex.
I love "coding"!

Rules

  • Use String variables.

  • Use + to combine text and variables.

  • Use escape characters like \" or \n.

  • Write your code inside main.

Java
public class Main {
public static void main(String[] args) {
// Write your code here:
}
}