Apuntes
intermediate java
Contenido del apunte (1)
Página 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!
Información
- Descripción
- Computer Science Apunte sobre intermediate java, creado por The RandomMan el 28/11/2024.
- Creado por
- The RandomMan
- Visitas
- 0
- Valoración