Notes
intermediate java
Content of the notes (1)
Page 1
System.out.printf() allows us to output strings that are formatted in the code using format specifiers. Format specifiers begin with the ‘%’ sign, followed by the type of variable we want to print. Some examples include %s for a string, %c for a character, and %d for an integer.
Let’s look at a modified version of the Java program that uses System.out.printf(). Notice that variables in our print statement are stated in the order that the format specifiers appear.
String world = "World";
int day = 1;
System.out.printf("Hello %s! Today is Day: %d of your Intermediate Java course!", world, day);
This code would show the following output in your program:
Hello World! Today is Day: 1 of your Intermediate Java course!
Information
- Description
- Computer Science Note on intermediate java, created by The RandomMan on 28/11/2024.
- Created by
- The RandomMan
- Views
- 0
- Rating