How to get the first element from ArrayList in Java

1 Answer

0 votes
import java.util.*;
   
public class MyClass {
    public static void main(String args[]) {
        ArrayList<Double> arrlist = new ArrayList<Double>();
          
        arrlist.add(89.12);
        arrlist.add(28.01);
        arrlist.add(47.98);
        arrlist.add(83.87);
        arrlist.add(99.31);

        System.out.println(arrlist.get(0)); 
    }
}
   
   
   
   
/*
run:
   
89.12
   
*/

 



answered Apr 22, 2020 by avibootz

Related questions

1 answer 187 views
1 answer 161 views
2 answers 155 views
1 answer 113 views
4 answers 471 views
1 answer 179 views
...