Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function HaHa($a = "Test")
- {
- print $a;
- }
- public void someFunction(int ttt = 5)
- {
- // something
- }
- int someMethod() { return someMethod(42); }
- int someMethod(int arg) { .... }
- public int getScore(int score, Integer... bonus)
- {
- if(bonus.length > 0)
- {
- return score + bonus[0];
- }
- else
- {
- return score;
- }
- }
- public void doSomething(boolean... arg1) {
- boolean MyArg1= (arg1.length >= 1) ? arg1: false;
- }
- public void methodA(A arg1) { }
- public void methodA( B arg2,) { }
- public void methodA(C arg3) { }
- public void methodA(A arg1, B arg2) { }
- public void methodA(A arg1, C arg3) { }
- public void methodA( B arg2, C arg3) { }
- public void methodA(A arg1, B arg2, C arg3) { }
- public static void main(String[] args)
- {
- defaultParameter();
- defaultParameter(true);
- }
- public static void defaultParameter(Boolean ...gender)
- {
- boolean genderBoolean = false; // It the default value you want to give
- if(gender.length == 1)
- {
- genderBoolean = gender[0]; // Overrided Value
- }
- System.out.println(genderBoolean);
- }
- false
- true
- if (ttt == 0) ttt = 5;
Add Comment
Please, Sign In to add comment