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

  • Home
  • SEARCH
  • 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 7741681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:05:15+00:00 2026-06-01T09:05:15+00:00

I am getting this error, but it isn’t very helpful in that it doesn’t

  • 0

I am getting this error, but it isn’t very helpful in that it doesn’t point me near where the error is happening. What do the numbers after the error mean? I have been looking at the error for the last few hours, but I don’t really get where the error is coming from. My code is:

val str = "(and x y)";

def stringParse ( exp: String, expreshHolder: ArrayBuffer[String] ): ArrayBuffer[String] = { //takes three arguments, string, int, arraybuffer

    var b = 0; //position of where in the expression String I am currently in
    var temp = expreshHolder; //holder of expressions without parens
    if(temp == 0) b = 0; else {b = temp(temp.length-1).toInt; temp.remove(temp.length-1)} //this sets the position of wherever the string was read last plus removes that check from the end of the ArrayBuffer
    var arrayCounter = temp.length; //just counts to make sure an empty spot in the array is there to put in the strings

    if(exp(b) == '(') {
        b = b + 1;

        while(exp(b) == ' '){b = b + 1;} //point of this is to just skip any spaces between paren and start of expression type
        if(exp(b) == 'a') {
            //first create the 'and', 'or', 'not' expression types to figure out 
            temp += exp(b).toString; 
            b = b+1; 
            temp(arrayCounter) = temp(arrayCounter) + exp(b).toString; //concatenates the second letter
            b = b+1; 
            temp(arrayCounter) = temp(arrayCounter) + exp(b).toString; //concatenates the last letter for the expression type
            arrayCounter+=1
            //this part now takes the symbols and puts them in an array
            b+=1;
            while(exp(b) == ' ') {b+=1;} //just skips any spaces until it reaches the first symbol
            if(exp(b) == '(') { temp += b.toString; temp = stringParse(exp, temp);
            b = temp(temp.length-1).toInt; 
            temp.remove(temp.length-1); 
            arrayCounter = temp.length 
            } else {
            temp += exp(b).toString; 
            arrayCounter+=1; b+=1; }
            while(exp(b) == ' ') {b+=1;} //just skips any spaces until it reaches the second symbol

            if(exp(b) == '(') { temp += b.toString; temp = stringParse(exp, temp); 
                            b = temp(temp.length-1).toInt; 
                            temp.remove(temp.length-1); 
                            arrayCounter = temp.length } else {temp += exp(b).toString; arrayCounter+=1; b+=1; }    
        }
    temp;
    } else { 
      temp(arrayCounter) +="failed"; temp;} //this is just incase it fails and I should probably check this incase it fails when it doesnt encounter an opening paren
}//end of while loop

hold = stringParse(str, ho );
for(test <- hold) println(test);

Sorry for the amount of code, but from what I can tell it is correct. The point of this code is to read this the first string at the top and just put “and”, “x”, “y” in an array. Its suppose to do it on more complicated ones, but I am trying it on a simple version first to test and make sure it works. The error I am getting is:

java.lang.ArrayIndexOutOfBoundsException: -1
at scala.collection.mutable.ResizableArray$class.apply(ResizableArray.scala:45)
at scala.collection.mutable.ArrayBuffer.apply(ArrayBuffer.scala:44)
at Driver$.stringParse$1(Driver.scala:19)
at Driver$.main(Driver.scala:60)
at Driver.main(Driver.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:78)
at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:24)
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:88)
at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:78)
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:33)
at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:40)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:56)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:80)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

any help on being able to read this error message and understand where it is happening? Thanks in advance.

  • 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-06-01T09:05:16+00:00Added an answer on June 1, 2026 at 9:05 am

    It means the variable you are decrementing has reached -1

    Also note that all you need do is follow the line numbers. For example, the first place to look is line ’45’

     scala.collection.mutable.ResizableArray$class.apply(ResizableArray.scala:45)
    

    Tackle the methods you wrote first.

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

Sidebar

Related Questions

I'm getting this error on Heroku but not locally (using PostgreSQL on both).. error
I am trying to install websvn but I am getting this error. Warning: proc_open()
I'm doing a Firefox addon but I'm currently getting this error in the Error
I am trying to create a 2 dimensional array but am getting this error.
I'm trying to connect to SSIS through SSMS but i keep getting this error:
Im trying to use Date Formatters (NSDateFormatter), but I keep getting this error: Program
I am trying to update code via Linq, but I am getting this error:
I am doing a minesweeper program for school, but i keep getting this error
We are trying to install: http://www.activecampaign.com/activespell/ But are getting this JS error: [CPAINT Error]
what i'm writing is simple, well, it should be, but i'm getting this error

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.