FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-programming/javaUpdates/src/array/MapHierarchy.java at master · 9146887137/java-programming · GitHub
9146887137
/
java-programming
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
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-programming
/
javaUpdates
/
src
/
array
/
MapHierarchy.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (21 loc) · 804 Bytes
Breadcrumbs
java-programming
/
javaUpdates
/
src
/
array
/
MapHierarchy.java
Copy path
File metadata and controls
26 lines (21 loc) · 804 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
package
array
;
import
java
.
util
.
Comparator
;
import
java
.
util
.
Map
;
import
java
.
util
.
TreeMap
;
import
java
.
util
.
Map
.
Entry
;
public
class
MapHierarchy
{
public
static
void
main
(
String
[]
args
) {
Comparator
<
Student
>
com
=(
s1
,
s2
)->
s1
.
age
>
s2
.
age
?
1
:
s1
.
age
<
s2
.
age
?-
1
:
0
;
Map
<
Student
,
String
>
map
=
new
TreeMap
<
Student
,
String
>(
com
);
map
.
put
(
new
Student
(
"ramesh"
,
23
),
"jalna"
);
map
.
put
(
new
Student
(
"abhijeet"
,
22
),
"Parbhani"
);
map
.
put
(
new
Student
(
"shubham"
,
24
),
"beed"
);
map
.
put
(
new
Student
(
"krishna"
,
21
),
"solapur"
);
map
.
put
(
new
Student
(
"aditya"
,
22
),
"dharashiv"
);
for
(
Student
st
:
map
.
keySet
()) {
System
.
out
.
println
(
map
.
get
(
st
));
//System.out.println(map.putIfAbsent(new Student("krishna", 21), "pune"));
}
System
.
out
.
println
(
map
.
values
());
}
}
Back
|
FazBrowse Home
|
New Git URL