GoConqr has a new look! Let us know what you think.

Notes

intermediate java

The RandomMan Computer Science English 1 page

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

Feedback

What is it about?

What do you think of the new look?

How do you like it?