Ask Question

How would you print out the value in the fourth index of an ArrayList of Doubles named myDoubles?

(This is Java Programming btw)

+4
Answers (1)
  1. 14 November, 03:29
    0
    You could make an ArrayList and get the 3rd Element in the array (Third because Arrays start at 0, making the Fourth one the third)

    Explanation:

    public class Main {

    public static ArrayList myDoubles = new ArrayList ();

    public static void main (String[] args) {

    myDoubles. add (1.0);

    myDoubles. add (2.0);

    myDoubles. add (3.0);

    myDoubles. add (4.0);

    double fourth = myDoubles. get (3);

    System. out. println (fourth); / / returns 4.0

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “How would you print out the value in the fourth index of an ArrayList of Doubles named myDoubles? (This is Java Programming btw) ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers