Coding Flashcards

1
Q

How do you create a List in Java?

A

List<Datatype> listName = new ArrayList<DataType>();</DataType></Datatype>

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

What method is used to add an elment to a list?

A

.add(element)

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

What method is used to remove an elment from a list?

A

.remove(index)

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

How do you create a set?

A

Set<Datatype> setName = new HashSet<>();</Datatype>

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

How do you add an element to a set?

A

.add(element)

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

How do you remove an elment from a set?

A

.remove(elment)

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

loop throught a set?

A

The same like regular arrays.

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

How do you create a map in java?

A

Map<KeyDataType, ValueDataType> = new HashMap<>();

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

How do you loop throught a map in Java

A

for(Map.Entry<KeyDataType, ValueDataType> entry : mapName.entrySet()){
//code
}

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

How do you add an elment into a map?

A

mapName.put(key, value)

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

How do your remove an elment from a map?

A

mapName.remove(key)

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

How do you get the key or value of a map entry?

A

entry.getKey();
entry.getValue();

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