fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes herepublic class MethodArguments {
  13.  
  14.  
  15. ArrayList<String> a = new ArrayList<String>();
  16.  
  17. a.add("Steve");
  18.  
  19. a.add("Daniel");
  20. a.add("John");
  21. a.add("Maxi");
  22. a.add("Jeni");
  23.  
  24. System.out.println(a);
  25.  
  26. display(a);
  27.  
  28. getSize(a);
  29.  
  30. }
  31.  
  32. static void display(ArrayList<String> arrayList1) {
  33.  
  34. arrayList1.add("Pollard");
  35.  
  36. System.out.println(arrayList1); // passing the arraylist values and
  37. // adding the element
  38.  
  39. }
  40.  
  41. static void getSize(ArrayList<String> arrayList1) {
  42.  
  43. System.out.println(arrayList1.size()); // getting the size of arraylist
  44. // by passing arguments to
  45. // method
  46. }
  47.  
  48. }
  49.  
Success #stdin #stdout 0.08s 27724KB
stdin
Standard input is empty
stdout
[Steve, Daniel, John, Maxi, Jeni]
[Steve, Daniel, John, Maxi, Jeni, Pollard]
6