Java Basics (Sorting, Classes)

c82-java-prog-logo

Sorting

if same time complexity, check
# of swaps
# of comparisons
o(n^2)
Insertion sort > Bubble sort > Selection sort
in place (maybe only o(1) space)
stable (same numbers’ relative position are same, 2,3,4,5(1),5(2))
o(nlogn)
Quick sort
o(1) extra space (in place)
not stable (random pivot, swap)
Merge sort
o(n) extra space (not in place)
Collections.sort(List<E> list) { list.sort() }
ArrayList, LinkedList, Arrays.sort()
Primitive Value Array: Tuned Quick sort (not stable, more efficient in memory)
Object Array: Merge sort (stable, i.e. Students might be sorted by age first, then height)
Insertion Sort when length < 7
-1 or less, 0 as equal, 1 or more as larger
Comparator
interface Comparator<T>
int compare(o1,o2)
Comparable
interface Comparable<T>
int compareTo(o1)
Iterator
hasNext();
next();
Iterable
List, Set, Map
Utility Classes and Methods
Collections.sort()
Arrays.sort()
Arrays
Arrays.asList()
Arrays.binarySearch()
Arrays.copyOf / copyOfRange
Arrays.deepEquals / deepHashcode / deepToString
Arrays.equals()
Arrays.fill()
Arrasy.toString()
String
String.toCharArray()
Character
Character.isUpperCase()
Character.isDigit()
Character.isAlphabetic()
Character.isSpace()
Character.toUpperCase()
Character.getNumericValue()
Static & Final
Static (class variable, function, class (nested) class)
Static class: static inner class, isolated from enclosing class instance
Static method: isolated from enclosing class instance
Static variable: called by static method
Static initializer: (run only once, even before constructor)
Final
Final class (cannot extend)
Final method (cannot override)
Final variable (cannot change the reference, compile error, but can change object member, can only be assigned be once)
Finally (a block, must execute after throw exception whether it’s caught or not)
Constant variable should be upper case
Final / Finally / Finalize (clean up processing before object is garbage collected)
Donate $5 to me for a coffee with PayPal and read more professional and interesting technical blog articles. Feel free to visit my web app, WhizWallet, to apply for credit, store or gift cards, DealsPlus to browse daily deals and store coupons to save money.
Follow me @Yaoli0615 at Twitter to get latest tech updates.
Resources:

Core Java Volume I–Fundamentals (10th Edition) (Core Series)

Core Java, Volume II–Advanced Features (10th Edition) (Core Series)

Test-Driven Java Development

Java Concurrency in Practice

Java: An Introduction to Problem Solving and Programming (7th Edition)

Java 9 for Programmers (Deitel Developer Series)

Java SE8 for the Really Impatient: A Short Course on the Basics (Java Series)

Core Java for the Impatient

Java: The Beginners Guide for every non-programmer which will attend you trough your learning process

Java Deep Learning Essentials

Machine Learning in Java

Learning Reactive Programming With Java 8

Java 9 Programming By Example

Thinking in Java (4th Edition)

The Java EE Architect’s Handbook, Second Edition: How to be a successful application architect for Java EE applications

Java Artificial Intelligence: Made Easy, w/ Java Programming

Advertisements

About liyao13

Yao Li is a web and iOS developer, blogger and he has a passion for technology and business. In his blogs, he shares code snippets, tutorials, resources and notes to help people develop their skills. Donate $5 to him for a coffee with PayPal at About Me page and read more professional and interesting technical blog articles. Follow him @Yaoli0615 at Twitter to get latest tech updates.
This entry was posted in CS Research&Application, Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s