0

I want the program to print A car with number of wheels has been created. Numbers of wheels = <wheels variable value>.

I tried to use place holder as in C# {0} or {1}: System.out.println("A car with {0} wheels created", wheels);

x80486
  • 6,627
  • 5
  • 52
  • 111

1 Answers1

1

use + as a way to concatenate strings, like so:

System.out.println("A car with " + wheels + " wheels has been created.") where wheels is your variable

Aiyuni
  • 780
  • 5
  • 15
  • 1
    ```System,out.printf("A car with %d wheels has been created.%n", wheels)``` seems to me easier to read, especially in cases where more than one insertion is wanted. –  Aug 02 '19 at 23:54