Java double Example

Have you ever met the situation that you get an integer but you really want a double? For the following method, devide(2,3) will return 0.0. public static double devide(int x, int y){ return x/y; }public static double devide(int x, int y){ return x/y; } The problem is that x/y does int division. If you want … Read more

Quicksort Array in Java

Quicksort is a divide and conquer algorithm. It first divides a large list into two smaller sub-lists and then recursively sort the two sub-lists. If we want to sort an array without any extra space, quicksort is a good option. On average, time complexity is O(n log(n)). The basic step of sorting an array are … Read more

Top 10 Algorithms for Coding Interview

This post summarizes the common subjects in coding interviews, including 1) String/Array/Matrix, 2) Linked List, 3) Tree, 4) Heap, 5) Graph, 6) Sorting, 7) Dynamic Programming, 8) Bit Manipulation, 9) Combinations and Permutations, and 10) Math. It is not alway easy to put a problem in one category, because the problem may belong to multiple … Read more

100 High-Quality Java Developers’ Blogs

The intent of this page is to collection the best 100 Java blogs and help programmers to find good blog posts to read. Some of these blogs may not be written by Java developers, but Java developers should find it useful or interesting. Reading those blogs should be fun and often bring some fresh ideas. … Read more

LeetCode – Sort List (Java)

LeetCode – Sort List: Sort a linked list in O(n log n) time using constant space complexity. Analysis If this problem does not have the constant space limitation, we can easily sort using a sorting method from Java SDK. With the constant space limitation, we need to do some pointer manipulation. Break the list to … Read more

Why Field Can’t Be Overridden?

This article shows the basic object oriented concept in Java – Field Hiding. 1. Can Field Be Overridden in Java? Let’s first take a look at the following example which creates two Sub objects. One is assigned to a Sub reference, the other is assigned to a Super reference. package oo;   class Super { … Read more