AkiVaMu Just tiny things come to mind...

jCenter vs Maven Central

This is an awesome article. Here is the summary:

  • jCenter and Maven Central are both Maven Repository
  • jCenter is hosted by bintray.com. Maven Central is hosted by sonatype.org.
  • Other can also host their own Maven Repo servers.
  • Should publish your library to standard server (e.g. jCenter and Maven Central…)
  • Maven Central is harder to publish to.
  • jCenter pros:
    • Use CDN
    • The largest Java Repository
    • Easy to publish library
more...

Sorting algorithms

This article will summarize about sorting algorithms, how they were named, and why use one over another.
Full information is in wikipedia already.
All opinions below are based on the simplest implementation of these sorting algorithms. There are many improved versions e.g. in-place Merge Sort, Quick Sort with O(NlogN) worst-case…, which are not mentioned here.

more...

How to untrack files in GIT

I accidentally commit some files that should not be tracked, e.g. folder .gradle, IntelliJ IDEA project file *.iml… Obviously that’s not good. Searching around, I found a thread in SOF, in summary:

  • Step 1: git rm --cached <files/folders>
  • Step 2: git update-index --no-assume-unchanged <files/folders>
  • Step 3: Add to .gitignore
more...

Java nested class

Definition

Nested class is declaring a class inside another class. There are 2 types:

  • Static nested class
  • Non-static nested class, divided into 3 types:
    • Inner class
    • Method local inner class
    • Anonymous
more...

Java varargs

Definition

This code declare a function that can take arbitrary number of parameters. The parameters must be the same type int.

void sampleFunction(int... args) {
    System.out.print(args.length);
    
    for (int i = 0; i < args.length; i++) {
        System.out.print(args[i]);
    }
}

It’s possible to mix varargs with other parameter types, like this:

void sampleMixingFunction(String name, Date date, int... args) {
    ...
}

The varargs must be the last parameters in function signature.
It’s not allowed to declare multiple varargs in one function.

more...