-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprintf.java
More file actions
35 lines (23 loc) · 817 Bytes
/
printf.java
File metadata and controls
35 lines (23 loc) · 817 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
25
26
27
28
29
30
31
32
33
34
35
public class printf {
public static void main(String[] args) {
int age = 26;
String myname = "Sujit Tomar";
int marks = 4155;
System.out.printf("My age is %d", age);
/*
Specifier Meaning
%d integer
%f float/double
%s string
%c char
%b boolean
%n new line
*/
System.out.printf("Name: %s Age: %d", "Sujit", 22);
System.out.println();
// Method First which is older
System.out.println("Hello " + myname + ", your marks is " + marks);
// Method Second which is newer
System.out.printf("Hello %-10S, your marks is %0,5d", myname, marks);
}
}