FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs/Hashset.java at main · shwetaodel/Java-Programs · GitHub
shwetaodel
/
Java-Programs
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programs
/
Hashset.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (27 loc) · 703 Bytes
Breadcrumbs
Java-Programs
/
Hashset.java
Copy path
File metadata and controls
38 lines (27 loc) · 703 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
package
core
;
import
java
.
util
.
HashSet
;
public
class
Hashset
{
public
static
void
main
(
String
[]
args
) {
HashSet
<
String
>
phones
=
new
HashSet
<
String
>();
phones
.
add
(
"Apple"
);
phones
.
add
(
"Samsung"
);
phones
.
add
(
"Moto"
);
phones
.
add
(
"Spark"
);
phones
.
add
(
"Oppo"
);
System
.
out
.
println
(
phones
);
//Check If an Item Exists
System
.
out
.
println
(
phones
.
contains
(
"Moto"
));
//Remove an Item
phones
.
remove
(
"Moto"
);
System
.
out
.
println
(
phones
);
//HashSet Size
System
.
out
.
println
(
phones
.
size
());
//HashSet with a for-each loop
for
(
String
i
:
phones
)
{
System
.
out
.
println
(
i
);
}
phones
.
clear
();
System
.
out
.
println
(
phones
);
}
}
Back
|
FazBrowse Home
|
New Git URL