in Education by
I have an ArrayList of LongArrays, each of size 2. I am trying to use the built-in 'indexOf' method to find the index of a specific array of longs, and I can't figure out why the code says the array of longs I'm searching for isn't found. See the below screen shot of a debugging session where try to evaluate finding 'longArrayOf(0L,5L)' in the ArrayList. In my mind, longArrayOf(0L,5L) is clearly the first element in the cardHierarchy array. Can the 'indexOf' function not be used for finding arrays? Can anyone suggest an alternate method? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
indexOf uses Object.equals() when you pass arrays, which compares by reference address which is different for the LongArray passed to indexOf and the one present in cardHierarchy. Change it to cardHierarchy.indexOfFirst { it.contentEquals(longArrayOf(0L, 5L)) }

Related questions

0 votes
    I have a webpage where Firefox 2 displays the font certain, really specific elements, larger than than what ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I have a webpage where Firefox 2 displays the font certain, really specific elements, larger than than what ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I have a webpage where Firefox 2 displays the font certain, really specific elements, larger than than what ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I am currently in the process of integrating Google Maps into one of our applications. One of the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    So I have this dataBase that is gonna be used in the app.get function below. The goal is to make ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    So I have this dataBase that is gonna be used in the app.get function below. The goal is to make ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    What is indexOf method in Java, I can't seem to find it anywhere. Also how do I use it? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Which of these exception is thrown in cases when the file specified for writing is not found? (a) IOException (b ... & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    What happens if ServerSocket is not able to listen on the specified port? (a) The system exits gracefully with ... & Servlet of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    (in UiPath)The Read PDF with OCR activity will throw an error if the following is not specified: The OCR Engine ... one may be chosen Select the correct answer from above options...
asked Dec 30, 2021 in Education by JackTerrance
0 votes
0 votes
    I'm trying to open up a PDF as an image using Wand. If I run the code below in Jupyter Notebook ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I'm trying to make a function in c to create and return a new struct similar to a constructor in ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I've been chasing around regular expressions for my .hgignore file, and found several very useful answers on ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
...