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. ArrayList<String> obj = new ArrayList<String>();
  13. Double d =0.0;
  14. /*This is how elements should be added to the array list*/
  15. obj.add("5.0");
  16. obj.add("3.5");
  17. obj.add("2.0");
  18. obj.add("2.5");
  19. obj.add("4.0");
  20. obj.add("3.5");
  21. for(int i = 0 ; i < obj.size() ; i++)
  22. d += Double.parseDouble(obj.get(i));
  23. System.out.println("Current array list is:"+d);
  24. }
  25. }
Success #stdin #stdout 0.05s 711168KB
stdin
Standard input is empty
stdout
Current array list is:20.5