Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7414367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:05:22+00:00 2026-05-29T07:05:22+00:00

I’m getting the following error: Exception in thread main java.lang.IndexOutOfBoundsException: Index: 86, Size: 86

  • 0

I’m getting the following error:

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 86, Size: 86
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at Netbooks.Recommendations.getDotProduct(Recommendations.java:72)
at Netbooks.TestRecomendations.main(TestRecomendations.java:11)
Java Result: 1

I’ve looked the code over many times and I can’t seem to find where I going over the index of the arraylist…

Here is the code for the dotProduct ArrayList:

public List<Integer> getDotProduct() throws IOException {
    Books book = new Books();
    Ratings cust = new Ratings();
    PureRatings pureRatings = new PureRatings();


    List<String> bookList = book.readBooks();
    List<String> customerList = cust.readCustomers();
    List<List<Integer>> pureRatingsList = pureRatings.parseRatingsFile();
    List<Integer> dotProduct = new ArrayList<Integer>();
    int index = getCustIndex();

    if (index == -1) {
        return dotProduct;
    }

    for (int i = 0; i < customerList.size(); i++) {
        int sum = 0;

        for (int j = 0; j < bookList.size(); i++) {
            if (i == index) {
                dotProduct.add(0);
            } else { //Next line is line 72.
                sum = sum + (pureRatingsList.get(index).get(j)) * (pureRatingsList.get(i).get(j)); //Line 72.
            }
        }
        dotProduct.add(sum);
    }

    return dotProduct;
}

And my main method (in another class) just in case:

public class TestRecomendations {

    public static void main(String[] args) throws IOException {
        Recommendations recomm = new Recommendations();

        List<Integer> dotProduct = recomm.getDotProduct();//Line 11.

        for (int i = 0; i < dotProduct.size(); i++) {
            System.out.println(dotProduct.get(i));
        }
    }
}

It should just print out the elements of the dotProduct ArrayList…

I don’t understand how line 72 is causing a problem since I should be able to add an unlimited number of items to the ArrayList….Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:05:22+00:00Added an answer on May 29, 2026 at 7:05 am

    The issue in line 72 is with a get(), not with an add().

    I suspect this could be the root cause of the problem:

    for (int i = 0; i < customerList.size(); i++) {
        int sum = 0;
    
        for (int j = 0; j < bookList.size(); i++) {  
            if (i == index) {
                dotProduct.add(0);
            } else { //Next line is line 72.
                sum = sum + (pureRatingsList.get(index).get(j)) * (pureRatingsList.get(i).get(j)); //Line 72.
            }
        }
        dotProduct.add(sum);
    }
    

    In the second for loop, you’re incrementing i and not j. That will probably result in you using a value for i in the line

    sum = sum + (pureRatingsList.get(index).get(j)) 
         * (pureRatingsList.get(i).get(j));
    

    larger than the size of pureRatingsList, resulting in the exception you’re seeing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.