-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintUtil.java
More file actions
24 lines (20 loc) · 790 Bytes
/
PrintUtil.java
File metadata and controls
24 lines (20 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Simplifying the print statements in Java
// 1) Simple print(), println(), and printf() functions
class PrintUtil {
// Creating static methods so no new instance has to be created
// Simple print() method
public static void print(String message) {
// Printing the output using traditional method
System.out.print(message);
}
// Simple println() method
public static void println(String message) {
// Printing the output using traditional method
System.out.println(message);
}
// Simple printf() method with formatting
public static void printf(String format, Object... args) {
// Printing the formatted output using traditional method
System.out.printf(format, args);
}
}