We are going to look at maps.
We have three classes that implement the interface for Map:
- HashMap (most popular)
- TreeMap (enties are sorted)
- LinkedHashMap (insertion order is kept)
We can envision this as follows:
Key | Value |
---|---|
StudentId | Program.java |
1234 | "public class Program{}" |
- put
- putAll
- remove
- clear
- containsKey
- containsValue
- isEmpty
- size
The keys of a map form a set.
Create a map from entires in two lists:
List<String> list = Arrays.asList( "one", "two", "three");
List<Integer> integers = Arrays.asList( 1, 2, 3);
Map<String, Integer> map = new HashMap<>();
for (int i = 0; i < list.size(); ++i){
map.put(list.get(i), integers.get(i));
}
isEmpty()
// Show isEmpty
if(duplicate.isEmpty()){
System.out.println("Duplicate is now officialy empty");
}
else {
System.out.println("I must have missed something");
Files can be classfied as:
- binary
- text
For now, we can think about text files as sequence of characters, and binary files as sequence of bytes.
- (before:) Read about Enums
- (and later:) Read about Enums