Question

Whats wrong with your program if it produces this error message when you try to run it (be specific) java.lang.ArrayIndexOut

in Java

0 0
Add a comment Improve this question Transcribed image text
Answer #1
You get IndexOutOfBoundsException exception 
when you are trying to access an array exceeds its length.

For example:
arr = {1,2,3,4,5}
Valid indexes for this array are 0 to 4.
When you are trying to access arr[10] then you get IndexOutOfBoundsException
Add a comment
Know the answer?
Add Answer to:
in Java What's wrong with your program if it produces this error message when you try...
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
  • Exercise 11 (2 pts.): When the following Matlab program is run, it produces an error. WHERE...

    Exercise 11 (2 pts.): When the following Matlab program is run, it produces an error. WHERE in the Matlab program does the error occur (underline the specific line of Matlab code that produces the error), and WHY does it occur? cleariclc A[-1, 0, -2, 3, 4, 61 Exercise 12 (2 pts.): When the following Matlab program is run, it produces an error. WHERE in the Matlab program does the error occur (underline the specific line of Matlab code that produces...

  • I need help debugging this Java program. I am getting this error message: Exception in thread...

    I need help debugging this Java program. I am getting this error message: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 at population.Population.main(Population.java:85) I am not able to run this program. ------------------------------------------------------------------- import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Scanner; /* Linked list node*/ class node { long data; long year; String country; node next; node(String c,long y,long d) { country=c; year=y; data = d; next = null; } } public class Population { private static node head; public static void push(String...

  • Select a Java program that contains an exception error. The exception error can be one that...

    Select a Java program that contains an exception error. The exception error can be one that you have encountered yourself or one you located using the Internet. Describe your chosen exception error and explain potential implications. Be sure to include the actual code in your posting. Prior to submission, check your colleagues' postings, as your post must contain a different error message from your colleagues.

  • in java Write a program that contains a bounds error. Run the program. What happens on...

    in java Write a program that contains a bounds error. Run the program. What happens on your computer?

  • In java write a command-line program that helps to decrypt a message that has been encrypted...

    In java write a command-line program that helps to decrypt a message that has been encrypted using a Caesar cipher1. Using this method, a string may contain letters, numbers, and other ASCII characters, but only the letters (upper- and lower-case) are encrypted – a constant number, the shift, is added to the ASCII value of each letter and when letters are shifted beyond ‘z’ or ‘Z’ they are wrapped around (e.g. “Crazy?” becomes “Etcba?” when shifted by 2). When your...

  • Do the following using JAVA language. a) Create an Error. (You can create any error.) b)...

    Do the following using JAVA language. a) Create an Error. (You can create any error.) b) Handle the error. c) Create a custom exception which will give a kind message. d) Handle both of the errors by using only one try-catch block.

  • Prelab Exercises Your task is to write a Java program that will print out the following...

    Prelab Exercises Your task is to write a Java program that will print out the following message (including the row of equal marks): Computer Science, Yes!!!! ========================= An outline of the program is below. Complete it as follows: a. In the documentation at the top, fill in the name of the file the program would be saved in and a brief description of what the program does. b. Add the code for the main method to do the printing. //...

  • Create a program that converts dollars to yen, euro, peso. Implement try....catch to handle unexpected user...

    Create a program that converts dollars to yen, euro, peso. Implement try....catch to handle unexpected user input. Program should not end with red error message. In Java please.

  • JAVA Problem Description: For this assignment, you will be writing your own exception class and you...

    JAVA Problem Description: For this assignment, you will be writing your own exception class and you will handle run-time exceptions resulting from one particular input situation. Specifics: 1) Design and implement a program that has an exception class called StringTooLongException, designed to be thrown when a string is discovered that has too many characters in it. 2) In the main driver of the program (call this class MyExceptionTest), read strings from the user until the user enters “DONE”. If a...

  • I'm working with Java and I have a error message  1 error Error: Could not find or...

    I'm working with Java and I have a error message  1 error Error: Could not find or load main class Flowers. This is the problem: Instructions Make sure the source code file named Flowers.java is open. Declare the variables you will need. Write the Java statements that will open the input file, flowers.dat, for reading. Write a while loop to read the input until EOF is reached. In the body of the loop, print the name of each flower and where...

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
ADVERTISEMENT