-
Notifications
You must be signed in to change notification settings - Fork 0
Java
Thomas Czogalik edited this page May 13, 2020
·
19 revisions
- Java is pass-by-value!
- volatile vs static variables
- what does serialization of an object mean?
- nested classes
- visibility and access of member
- Generics and Collections
- Streams
- Java Operator Precedence
- Projekt Lombok boilerplate code reduction
-
JavaBean is just a standard
- All properties private (use getters/setters)
- A public no-argument constructor
- Implements Serializable.
-
- HashMap makes absolutely no guarantees about the iteration order. It can (and will) even change completely when new elements are added.
- TreeMap will iterate according to the "natural ordering" of the keys according to their compareTo() method (or an externally supplied Comparator). Additionally, it implements the SortedMap interface, which contains methods that depend on this sort order.
- LinkedHashMap will iterate in the order in which the entries were put into the map
-
Adding duplicate to set:
- In the case of HashMap, it replaces the old value with the new one.
- In the case of HashSet, the item isn't inserted.
static {
System.out.println("static init block")
}
{
System.out.println("init block")
}
- static block is called once when class is loaded
- used to init static variables
- init block is always called on object creation
- used for code that is shared among multiple constructors
- is called before constructor
- is copied by compiler into constructor