tubeshowcase●1,194,391 videos♡ My collection 0
← Learn to Code

Learn to Code13:37

Java printf() is really useful! 🖨️

Bro Code ↗

From the creator

#java #javatutorial #javacourse public class Main { public static void main(String[] args) { // printf() is a method used to format output // % [flags] [width] [.precision] [specifier-character] // [specifier-character] String name = "Spongebob"; char firstLetter = 'S'; int age = 30; double height = 60.5; boolean isEmployed = true; System.out.printf("Hello %s\n", name); System.out.printf("Your name starts with a %c\n", firstLetter); System.out.printf("You are %d years old\n", age); System.out.printf("You are %f inches tall\n", height); System.out.printf("Employed: %b\n", isEmployed); System.out.printf("%s is %d years old", name, age); // [.precision] double price1 = 9.99; double price2 = 100.15; double price3 = -54.01; System.out.printf("%.3f\n", price1); System.out.printf("%.3f\n", price2); System.out.printf("%.3f\n", price3); // [flags] // + = output a plus // , = comma grouping separator // ( = negative numbers are enclosed in () // space = display a minus if negative, space if positive System.out.printf("%f\n", price1); System.out.printf("%f\n", price2); System.out.printf("%f\n", price3); // [width] // 0 = zero padding // number = right justified padding // negative number = left justified padding int id1 = 1;

Published 2024-12-05 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code