Here I draw some diagrams to show how arrays look like in memory and in cache. This is not a programming problem, but let’s assume we use C not Java.
Month: October 2012
8 Things Programmers Can Do at Weekends
Weekends are an important time to unplug from the day-to-day job and get recharged. They are also a good chance to think more deeply about things. Software programmer (developer or engineer) is a special occupation comparing to others, even though many jobs require the use of computers. Inspired by “14 Things Successful People Do On … Read more
Loop an Iterable in Java
If you use some Java API and it returns an Iterable, such as Iterable, you may want to loop this iterable. The method is pretty simple as follows: Iterable<String> result = … //result returned from some method. for(String s: result){ System.out.println(s); }Iterable<String> result = … //result returned from some method. for(String s: result){ System.out.println(s); } … Read more
Iteration vs. Recursion in Java
1. Recursion Consider the factorial function: n!=n*(n-1)*(n-2)*…*1 There are many ways to compute factorials. One way is that n! is equal to n*(n-1)!. Therefore the program can be directly written as: Program 1: int factorial (int n) { if (n == 1) { return 1; } else { return n*factorial(n-1); } }int factorial (int n) … Read more
IBM WALA tutorial
Below is a tutorial for showing how to use Wala to do static program analysis. It is done under windows. WALA is a bundle of java libraries for software analysis which is initially developed by IBM T.J. Watson Research Center. It has capacities to analyze the code of several programming languages. In this simple tutorial, … Read more
Eclipse PlatformUI Examples
In this tutorial, I will use examples to show you how to use the Eclipse PlatformUI class. PlatformUI is a final class defined in org.eclipse.ui package. It provides access function to the Eclipse Platform User Interface. All methods inside of PlatformUI class are static and the class can not be initialized. Example 1: Fetch current … Read more
Make “Facebook and Twitter share buttons” WordPress Plugin Float Correctly on Left Side of Post.
Facebook and Twitter share buttons is a good plugin for sharing. But it does not float correctly on left side of post. If the screen is too small, the button will overlap each post. In the following I will make some changes and then the buttons always float on the left side of post. Editing … Read more