Displaying a message using integer and string variables

Report a typo

In a basic Java program, you are tasked to display a message that includes an integer and a string. This will allow you to demonstrate your understanding of using both primitive and reference data types. You are required to define an integer variable, set its value to 10, define a string variable, set its value to 'Hello, World!', and then print a message that includes these variables. To complete this task, you have to reorder the lines of code correctly.

Reorder lines using drag or arrows. Adjust indentation with left buttons
                }
              
                public class Main {
              
                System.out.println("My number is " + myNumber + " and my string is '" + myString + "'.");
              
                String myString = "Hello, World!";  //reference type
              
                }
              
                int myNumber = 10;  //primitive type
              
                public static void main(String[] args) {
              
___

Create a free account to access the full topic