8 Array

example:

Seeking a double array containing all elements and

Package com.wys.java; 

public  class arraylistDemo {
     public  static  void main (String [] args) {
         int size =. 5 ;
         Double [] myList = new new  Double [size]; 
        myList [ 0] = 0.1 ; 
        myList [ . 1] = 0.2 ; 
        myList [ 2] = 0.3 ; 
        myList [ . 3] = 0.4 ; 
        myList [ . 4] = 0.5 ; 

        // sum of all the elements 
        Double sUM = 0.0 ;
         for ( int i=0; i<size; i++){
            sum+=myList[i];
        }
        System.out.println("sum is: "+sum);
    }
}

Guess you like

Origin www.cnblogs.com/CPU-Easy/p/12099713.html