vimwiki/tech/Java.wiki

56 lines
2.1 KiB
Plaintext
Raw Normal View History

2022-03-30 15:45:01 +00:00
= Java =
Java is a strongly typed, garbage collected language that runs in the JVM. It
can run on almost anything.
== Data structures ==
2022-03-30 16:15:01 +00:00
| C++ DS | Java DS | Notes |
| Vector | ArrayList | Threadsafe |
| Vector | Vector | Not threadsafe; deprecated |
| Deque | Deque | |
| Stack | Stack | Stack implementation using a vector |
| List | ArrayList | Both linked lists; Singly linked |
| List | LinkedList | Doubly linked list |
| Map | TreeMap | Red-black tree |
| Set | TreeSet | Red-black tree |
| unordered_set | Hashset | Hashtable |
| unordered_map | Hashmap | Non blocking but race conditions can occour |
| unordered_map | Hashtable | Threadsafe but blocking; deprecated |
| N/A | LinkedHashMap | LRUCache; Hash table that knows order of elements inserted/accessed |
| N/A | LinkedHashSet | LRUCache; Hash set that knows order of elements inserted/accessed |
2022-03-30 16:00:01 +00:00
== Classes ==
=== Constructor ===
{{{
public class MyClass{
public MyClass(){
//constructor code here
}
}
}}}
2022-03-30 16:15:01 +00:00
=== Deconstructor/Finalize ===
finalize provides security and is called by the garbage collector. We can call
it directly to clean up the object. All exceptions thrown by it are ignored by
the garbage collector.
{{{
public class MyClass{
public MyClass(){
//constructor code here
}
protected void finalize(){
//clean up code here
}
}
}}}
2022-03-30 15:45:01 +00:00