Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
Java. training
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Qazi Zain
Java. training
Commits
80c3c8d0
Commit
80c3c8d0
authored
Oct 09, 2024
by
Qazi Zain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Map code is added
parent
edcbcf08
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
CoustomHashMap.java
src/MapInterface/CoustomHashMap/CoustomHashMap.java
+38
-0
Main.java
src/MapInterface/CoustomHashMap/Main.java
+7
-0
No files found.
src/MapInterface/CoustomHashMap/CoustomHashMap.java
0 → 100644
View file @
80c3c8d0
package
MapInterface
.
CoustomHashMap
;
import
java.util.*
;
public
class
CoustomHashMap
{
HashMap
<
Integer
,
String
>
obj
=
new
HashMap
<>();
CoustomHashMap
()
{
System
.
out
.
println
(
"Coustom HaspMap object is created!"
);
}
void
displayHashMap
()
{
// add value in HashMap.
obj
.
put
(
1
,
"zain"
);
obj
.
put
(
2
,
"ali"
);
obj
.
put
(
3
,
"zain"
);
// value iss duplicate and key is unique it will add.
obj
.
put
(
1
,
"zain"
);
// this will not add because key isn't unique.
System
.
out
.
println
(
"Values in Hash Map:"
+
obj
);
// Searching in map.
if
(
obj
.
containsKey
(
2
))
{
System
.
out
.
println
(
"ali is in hash table as a record"
);
}
// get value
System
.
out
.
println
(
"value of key 3 is:"
+
obj
.
get
(
3
));
}
}
src/MapInterface/CoustomHashMap/Main.java
0 → 100644
View file @
80c3c8d0
package
MapInterface
.
CoustomHashMap
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment