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 arrayTest {
  9. public static void main(String [] args){
  10. double[] myList= {12.0,6.5,7.5,5.0,2.5,10.0,20.0};
  11. for(int i =0; i<myList.length;i++){
  12. System.out.println(i + ":" + myList[i] );
  13. }
  14. double total = 0;
  15. for(int j= 0;j<myList.length; j++){
  16. total+=myList[j];
  17. // System.out.println("Total is " + total);
  18. }
  19. System.out.println("Total is " + total);
  20. }
  21. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
0:12.0
1:6.5
2:7.5
3:5.0
4:2.5
5:10.0
6:20.0
Total is 63.5