JAVA Part 3 Flashcards
1
Q
How to iterate through a list efficiently?
A
for (TypeOfVariable nameOfVariable: nameOfList)
2
Q
How to check if a string list is empty?
A
list.isEmpty()
3
Q
How to add an element to a list?
A
list.add()
4
Q
How to retrieve a value from a list?
A
String string = list.get()
5
Q
How to remove a element from a list?
A
list.remove()
6
Q
How to check if an element is in a list?
A
list.contains()
7
Q
What is explicit initialisation used for?
A
Constants and static fields
8
Q
What is static keyword in java?
A
The static keyword indicates that a member of a class that does not belong to the instance of the class, thus shared among all objects if this class