MAPS Flashcards

1
Q

MAPS replace die ou?

A

Dictionary Abstract Class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How verklaar n mens n map?

A

Map <String, String> tale = new HashMap<>();
So die eerste “String” dui op die datatipe van die key
So die tweede “String” dui op die datatipe van die objek wat saam met die spesifieke key gaan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Metode om iets nuuts in n map te sit:

A

.put(key, objek)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Om iets te kry uit n map uit?

A

.get(key)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Keys in n map is uniek, so dit is baie maklik om n borige di g te override. Hoe kan jy eers kyl asof n seker map n seker key het?

A

Deur gebruik te maak van .containsKey()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

So anders as n Arraylist, kan ek nie net sit for(Hond temp: honde) by n map nie?

A

Korrek, die map kort n .keySet() agterna om elke element te kan uitkry

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Hoe verwyder ons iets uit n map uit?

A

.remove(key)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Wat as ek iets uit n map wil verwyder, maar net as die pair bestaan? Maw die containing object n seker waarde het?

A

Languages.remove(key, object)

Wat ook interessant is, hierdie ding return actually n boolean so hy sal true wees as hy suksesvol was

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Hoe split n mens n lang string in woorde in?

A

String a[] = Stringaa.split(“ “);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Wanneer j van die console af lees, watter metode moet jy gebruik in die scanner klas?

A

scanner.readline()
As jy net read() het, doen die compiler iets baie snaaks…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Hoe vervang mens n element pair in n map?

A

Languages.replace(“Lis”,xxxz)
Hierdie key moet bestaan, anders doen hy niks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Deel van immutable klasse ook, maar in die voorbeeld van die adventure game, hoe het hy die map return uit die klas?

A

Public Map <String,Integer> getExists(){
Return new HashMap <String,Integer> (exists);}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly