Java Coding Practices : Simple rules to Optimise your code and make it work faster
http://www.capitalware.com/dl/docs/WhitePaperJavaCodingPractices.pdf
- Garbage collection
- Loop optimisation
- Data Structures
- Synchronization
- Exception Handling - A simple performance improvement can be achieved by placing the try-catch block outside any loops.
- Set - no particular order, sets are slower than most other collection objects. No duplicates
- HashSet - HashSet stores the object in random order.There is no guarantee that the element we inserted first in the HashSet will be printed first in the output
- TreeSet - Elements are sorted according to the natural ordering of its elements in TreeSet
- List - A list has the characteristics that objects are stored in a linear manner
- ArrayList - Ordered list the order in which elements are entered is maintained
- Vector - Dynamic array. Synchronised
- Stack - LIFO last in first out
- LinkedList - Internally uses doubly linked list faster than array list
- Hash - Maps involve pairs of objects, a key and the object itself.
- Hash Map - no order in key value pair stored.
- Tree Map - ordered by key
- Linked Hash Map - insertion order maintained.
- Hash table - synchronised hash table
Some useful links :
http://tutorials.jenkov.com/java-collections/stack.html
Comments
Post a Comment