Question

in java.... write a segment of code that declares an array variable, create an array object...

in java....

write a segment of code that declares an array variable, create an array object that can hold 20 integers assigns the array object to the array variable, and then uses a loop to fill the array with the following integers...

0,10,20,30,40,50,60,70,80,90,100

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// write a segment of code that declares an array variable,
// create an array object that can hold 20 integers assigns the array object to the array variable,
int[] arr = new int[20];

// and then uses a loop to fill the array with the following integers...
// 0,10,20,30,40,50,60,70,80,90,100
for (int i = 0; i < 11; i++) {
    arr[i] = i * 10;
}

import java.util.Arrays;

public class ArraySegment {

    public static void main(String[] args) {
        // write a segment of code that declares an array variable,
        // create an array object that can hold 20 integers assigns the array object to the array variable,
        int[] arr = new int[20];

        // and then uses a loop to fill the array with the following integers...
        // 0,10,20,30,40,50,60,70,80,90,100
        for (int i = 0; i < 11; i++) {
            arr[i] = i * 10;
        }

        System.out.println(Arrays.toString(arr));
    }
}

Add a comment
Know the answer?
Add Answer to:
in java.... write a segment of code that declares an array variable, create an array object...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT