Here's a great explanation of the difference between space complexity and time cplexity:
What do you mean by space complexity?
Space complexity is a measure of the amount of working storage an algorithm needs. That means how much memory, in the worst case, is needed at any point in the algorithm. As with time complexity, we're mostly concerned with how the space needs grow, in big-Oh terms, as the size N of the input problem grows.
Time complexity i usually the thing we care about in computer science.
- Array - has access time complexity O(1)
- ArrayList is fast at accessing elements and slow at adding and removing elements
- LinkedList is slow at accessing elements and fast at adding and removing elements.
In general use ArrayList over LinkedList because it's fast for accessing a random element.
Coupling - measures how much you need to change other classes after changing one class (minimize coupling as much as possible)
Cohesion - a measure of whether a class's responsibilities form a meaningful unit. Keep in mind the single responsibility rule.
Inner Classes - Useful if you want to restrict the scope of a class. In general, it's not good practice to use inner classes.
Inner Classes - Constructor chaining - When a subclass constructor is run, it will automatically call "super();". You can explicitly set it and pass in parameters (useful when superclass constructor takes parameters).
Copy Constructor - a constructor of a class which accepts the same class as a parameter in its constructor.
Assert - let's you use unit testing code right in your application!
Reflection - Gives you details about particular implementation of a particular class, eg. how many methods or private, public, etc. Gives you details about the class interface. Use the ".class" property.
Collection - A base interface in collections framework. Gives you the ability to add a remove values to a group.
Set - an interface that is the same as Collection except that it must contain unique values
List - Also extends Collection, Position is important, an interface where everything is in order, allows duplicates.
Queue - Stores a list of values in a way that you can easily get the first and last values.
Map - Does NOT extend the collections interface. Uses key-value pairs.
HashSet - neither ordered nor sorted, iterates in random order, uses "hashcode"
LinkedHashSet - ordered, but unsorted, just stores things in the order of insertion.
TreeSet - Elements get saved in a SORTED order (not in order of insertion)
ArrayList - Implements random access, insertion and deletion are slower compared to linkedlist.
LinkedList - elements are "linked forward and backward" to each other. Ideal choice for stack or queue. Iteration is slower than ArrayList, but fast insertion / deletion
- objects are pass by reference, primitives svalue
- String is immutable
- StringBuffer is not immutable but is sychronized
- final: cannot change the value and cannot be overridden / extended
- Interfaces only contin the method signature, not the body of the function
- Abstract Classes are Nouns (AbstractClassExample) while interfaces are usually action words (runnable, flyable).
- collections - has a lot of utility methods like sort, minimum, maximum
- binary search
- shuffle - random order
- minimum, maximum
Collections Class has a lot of static methods for using on things that implement the collections interface.