FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-basics/core-java/strings/StringJoinerClass.java at patch-1 · CodeForHunger/java-basics · GitHub
CodeForHunger
/
java-basics
Public
forked from
learning-zone/java-basics
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-basics
/
core-java
/
strings
/
StringJoinerClass.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (28 loc) · 841 Bytes
Breadcrumbs
java-basics
/
core-java
/
strings
/
StringJoinerClass.java
Copy path
File metadata and controls
39 lines (28 loc) · 841 Bytes
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
package
strings
;
import
java
.
util
.
ArrayList
;
import
java
.
util
.
StringJoiner
;
public
class
StringJoinerClass
{
public
static
void
main
(
String
[]
args
) {
ArrayList
<
String
>
a1
=
new
ArrayList
<>();
a1
.
add
(
"Ram"
);
a1
.
add
(
"Shyam"
);
a1
.
add
(
"Alice"
);
a1
.
add
(
"Bob"
);
StringJoiner
sj1
=
new
StringJoiner
(
", "
);
// SetEmptyValue() method
sj1
.
setEmptyValue
(
"sj1 is empty"
);
System
.
out
.
println
(
sj1
);
// add() method
sj1
.
add
(
a1
.
get
(
0
)).
add
(
a1
.
get
(
1
));
System
.
out
.
println
(
sj1
);
// length method
System
.
out
.
println
(
"Length of string: "
+
sj1
.
length
());
StringJoiner
sj2
=
new
StringJoiner
(
" : "
);
sj2
.
add
(
a1
.
get
(
2
)).
add
(
a1
.
get
(
3
));
// merge() method
sj1
.
merge
(
sj2
);
// toString() method
System
.
out
.
println
(
sj1
.
toString
());
System
.
out
.
println
(
"Length of new string: "
+
sj1
.
length
());
}
}
Back
|
FazBrowse Home
|
New Git URL