FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
OnJava8-Examples/strings/Conversion.java at master · CSapprenticeWT/OnJava8-Examples · GitHub
CSapprenticeWT
OnJava8-Examples
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
OnJava8-Examples
/
strings
/
Conversion.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
113 lines (106 loc) · 2.52 KB
Breadcrumbs
OnJava8-Examples
/
strings
/
Conversion.java
Copy path
File metadata and controls
113 lines (106 loc) · 2.52 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// strings/Conversion.java
// (c)2021 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
import
java
.
math
.*;
import
java
.
util
.*;
public
class
Conversion
{
public
static
void
main
(
String
[]
args
) {
Formatter
f
=
new
Formatter
(
System
.
out
);
char
u
=
'a'
;
System
.
out
.
println
(
"u = 'a'"
);
f
.
format
(
"s: %s%n"
,
u
);
// f.format("d: %d%n", u);
f
.
format
(
"c: %c%n"
,
u
);
f
.
format
(
"b: %b%n"
,
u
);
// f.format("f: %f%n", u);
// f.format("e: %e%n", u);
// f.format("x: %x%n", u);
f
.
format
(
"h: %h%n"
,
u
);
int
v
=
121
;
System
.
out
.
println
(
"v = 121"
);
f
.
format
(
"d: %d%n"
,
v
);
f
.
format
(
"c: %c%n"
,
v
);
f
.
format
(
"b: %b%n"
,
v
);
f
.
format
(
"s: %s%n"
,
v
);
// f.format("f: %f%n", v);
// f.format("e: %e%n", v);
f
.
format
(
"x: %x%n"
,
v
);
f
.
format
(
"h: %h%n"
,
v
);
BigInteger
w
=
new
BigInteger
(
"50000000000000"
);
System
.
out
.
println
(
"w = new BigInteger(
\"
50000000000000
\"
)"
);
f
.
format
(
"d: %d%n"
,
w
);
// f.format("c: %c%n", w);
f
.
format
(
"b: %b%n"
,
w
);
f
.
format
(
"s: %s%n"
,
w
);
// f.format("f: %f%n", w);
// f.format("e: %e%n", w);
f
.
format
(
"x: %x%n"
,
w
);
f
.
format
(
"h: %h%n"
,
w
);
double
x
=
179.543
;
System
.
out
.
println
(
"x = 179.543"
);
// f.format("d: %d%n", x);
// f.format("c: %c%n", x);
f
.
format
(
"b: %b%n"
,
x
);
f
.
format
(
"s: %s%n"
,
x
);
f
.
format
(
"f: %f%n"
,
x
);
f
.
format
(
"e: %e%n"
,
x
);
// f.format("x: %x%n", x);
f
.
format
(
"h: %h%n"
,
x
);
Conversion
y
=
new
Conversion
();
System
.
out
.
println
(
"y = new Conversion()"
);
// f.format("d: %d%n", y);
// f.format("c: %c%n", y);
f
.
format
(
"b: %b%n"
,
y
);
f
.
format
(
"s: %s%n"
,
y
);
// f.format("f: %f%n", y);
// f.format("e: %e%n", y);
// f.format("x: %x%n", y);
f
.
format
(
"h: %h%n"
,
y
);
boolean
z
=
false
;
System
.
out
.
println
(
"z = false"
);
// f.format("d: %d%n", z);
// f.format("c: %c%n", z);
f
.
format
(
"b: %b%n"
,
z
);
f
.
format
(
"s: %s%n"
,
z
);
// f.format("f: %f%n", z);
// f.format("e: %e%n", z);
// f.format("x: %x%n", z);
f
.
format
(
"h: %h%n"
,
z
);
}
}
/* Output:
u = 'a'
s: a
c: a
b: true
h: 61
v = 121
d: 121
c: y
b: true
s: 121
x: 79
h: 79
w = new BigInteger("50000000000000")
d: 50000000000000
b: true
s: 50000000000000
x: 2d79883d2000
h: 8842a1a7
x = 179.543
b: true
s: 179.543
f: 179.543000
e: 1.795430e+02
h: 1ef462c
y = new Conversion()
b: true
s: Conversion@19e0bfd
h: 19e0bfd
z = false
b: false
s: false
h: 4d5
*/
Back
|
FazBrowse Home
|
New Git URL