FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-programs/LearnTreeMap.java at main · tejaspundpal/Java-programs · GitHub
tejaspundpal
/
Java-programs
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
2
Code
Issues
0
Pull requests
2
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
/
LearnTreeMap.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (28 loc) · 984 Bytes
Breadcrumbs
Java-programs
/
LearnTreeMap.java
Copy path
File metadata and controls
31 lines (28 loc) · 984 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
import
java
.
util
.*;
public
class
LearnTreeMap
{
public
static
void
main
(
String
[]
args
) {
Map
<
String
,
Integer
>
numbers
=
new
TreeMap
<>();
numbers
.
put
(
"one"
,
1
);
numbers
.
put
(
"five"
,
5
);
numbers
.
put
(
"two"
,
2
);
numbers
.
put
(
"three"
,
3
);
numbers
.
put
(
"eight"
,
8
);
//numbers.put("two",22); ------> override the old value
//numbers.putIfAbsent("two",22);
System
.
out
.
println
(
numbers
);
for
(
Map
.
Entry
<
String
,
Integer
>
e
:
numbers
.
entrySet
()){
System
.
out
.
println
(
e
);
}
// for(Map.Entry<String,Integer> e: numbers.entrySet()){
// System.out.println(e.getKey());
// System.out.println(e.getValue());
// }
for
(
String
key
:
numbers
.
keySet
()){
System
.
out
.
println
(
key
);
}
System
.
out
.
println
(
numbers
.
containsKey
(
"one"
));
numbers
.
replace
(
"one"
,
1
,
11
);
System
.
out
.
println
(
numbers
);
}
}
Back
|
FazBrowse Home
|
New Git URL