FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-basics/core-java/collections/HashSetMerge.java at master · 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
/
collections
/
HashSetMerge.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
29 lines (22 loc) · 676 Bytes
Breadcrumbs
java-basics
/
core-java
/
collections
/
HashSetMerge.java
Copy path
File metadata and controls
29 lines (22 loc) · 676 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
package
collections
;
import
java
.
util
.*;
public
class
HashSetMerge
{
public
static
<
T
>
Set
<
T
>
mergeSet
(
Set
<
T
>
a
,
Set
<
T
>
b
) {
//Creating an empty set
Set
<
T
>
mergedSet
=
new
HashSet
<
T
>();
mergedSet
.
addAll
(
a
);
mergedSet
.
addAll
(
b
);
return
mergedSet
;
}
public
static
void
main
(
String
[]
args
) {
//First Set
Set
<
Integer
>
a
=
new
HashSet
<
Integer
>();
a
.
addAll
(
Arrays
.
asList
(
new
Integer
[] {
1
,
3
,
5
,
7
,
9
}));
//Second Set
Set
<
Integer
>
b
=
new
HashSet
<
Integer
>();
b
.
addAll
(
Arrays
.
asList
(
new
Integer
[] {
0
,
2
,
4
,
6
,
8
}));
System
.
out
.
println
(
"Set a: "
+
a
);
System
.
out
.
println
(
"Set b: "
+
b
);
System
.
out
.
println
(
"Merged Set: "
+
mergeSet
(
a
,
b
));
}
}
Back
|
FazBrowse Home
|
New Git URL