Android: How to set a default value for an argument variable

No, Java does not support default values for function parameteres. There's an interesting post about borrowing language features here: http://java.dzone.com/news/default-argument-values-java


You can abuse overloading like this:

int someMethod() { return someMethod(42); }
int someMethod(int arg) { .... }

you can use 3 dots syntax:

public void doSomething(boolean... arg1) {
    boolean MyArg1= (arg1.length >= 1) ? arg1 : false;
}

No need to overload anything, just write:

public int getScore(int score, Integer... bonus)
{
    if(bonus.length > 0)
    {
        return score + bonus[0];
    }
    else
    {
        return score;
    }
}