Question

Java: What are the most common mistake of a one dim array?

Java: What are the most common mistake of a one dim array?

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

1) The most common mistake that I have seen people do is assuming that 1d array starts from index 1, but actually it starts from index 0.

2) Some people also try to use an array declaration in a function call.

For example:

int num[N] = {1, 2, 3, 4};

printArray(int num[N]); // this is wrong, instead it should be printArray(num)

3) Again, some people get index out of bound exception because of using <= in a for() loop, not <.

For example,
for(i = 0; i <= N; ++i)
    num[i] = i;
Add a comment
Know the answer?
Add Answer to:
Java: What are the most common mistake of a one dim array?
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