COLLAPSE 1 Give us an example of declaring an array and then

COLLAPSE

1. Give us an example of declaring an array and then a loop that assigns a random number from 20 to 200 to each array element - this should be a single statement in the loop body. End the short piece of code with a foreach construct to output those values.

2. Give us an example that declares and assigns values to an array for some set of values (6 or so) using the bottom of page 248 as an example.

3. Show us an example of a method header statement that accepts an array of type String and is of type String[].

Using netbeans

Solution

1.

2. int a[10]={6,12,18,24,30,36,42,48,54,60};

->delares and assigns values to array named a with the following values given in braces.

COLLAPSE 1. Give us an example of declaring an array and then a loop that assigns a random number from 20 to 200 to each array element - this should be a single

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site