Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer ASAP will upvote! Problem 5 (10pts): If I have a java.util. Arraytist called that holds values of type and I want to sum

image text in transcribedplease answer ASAP will upvote!

Problem 5 (10pts): If I have a java.util. Arraytist called that holds values of type and I want to sum them up, then I can create the following code to sum up the list: \begin{tabular}{|l|l} 1 & double sum = 0; \\ 2 & for(Double val : doublelist) \{ \\ 3 & sum t= val; \\ 4 & \} \end{tabular} Java autounboxes val into an during each iteration of the loop. If I have a similar java.util. Arraylist called that holds values of type and I want to sum them up, then l'd like to do the same thing but with as , like so: \begin{tabular}{l|l} 1 & long sum =0 \\ 2 & for(Number val : numList) \{ \\ 3 & sum += val; \\ 4 & \} \end{tabular}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions