Guest User

Untitled

a guest
Jul 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. function HaHa($a = "Test")
  2. {
  3. print $a;
  4. }
  5.  
  6. public void someFunction(int ttt = 5)
  7. {
  8. // something
  9. }
  10.  
  11. int someMethod() { return someMethod(42); }
  12. int someMethod(int arg) { .... }
  13.  
  14. public int getScore(int score, Integer... bonus)
  15. {
  16. if(bonus.length > 0)
  17. {
  18. return score + bonus[0];
  19. }
  20. else
  21. {
  22. return score;
  23. }
  24. }
  25.  
  26. public void doSomething(boolean... arg1) {
  27. boolean MyArg1= (arg1.length >= 1) ? arg1: false;
  28. }
  29.  
  30. public void methodA(A arg1) { }
  31. public void methodA( B arg2,) { }
  32. public void methodA(C arg3) { }
  33. public void methodA(A arg1, B arg2) { }
  34. public void methodA(A arg1, C arg3) { }
  35. public void methodA( B arg2, C arg3) { }
  36. public void methodA(A arg1, B arg2, C arg3) { }
  37.  
  38. public static void main(String[] args)
  39. {
  40. defaultParameter();
  41. defaultParameter(true);
  42. }
  43.  
  44. public static void defaultParameter(Boolean ...gender)
  45. {
  46. boolean genderBoolean = false; // It the default value you want to give
  47. if(gender.length == 1)
  48. {
  49. genderBoolean = gender[0]; // Overrided Value
  50. }
  51. System.out.println(genderBoolean);
  52. }
  53.  
  54. false
  55. true
  56.  
  57. if (ttt == 0) ttt = 5;
Add Comment
Please, Sign In to add comment