I am going to say something I shouldn't:-
Tobias Totti wrote:. . . the Ranch will get me over the trauma of using [website XYZ] . . .
Which video? There are videos out there by the thousand and some aren't any good. They may give you an out of date solution or an incomplete solution or insuffifent explanation so you end up writing something and not knowing what you wrote Generics was introduced 16½ years ago, so anybody writing compareTo(Object) is horribly out of date. Very briefly, generics obviates the tempation to write casts, which you had to use before.
. . . compareTo method I was using worked fine when I changed the method to fit the template in the video.
We'd have to see your code to know about that.
I think it's probable that it was looping through incorrectly and nulling values that had already been filled . . .
An index out of bounds exception suggests an index ≥ theArray.length or < 0, and a common way to get such errors is by not writing a loop correctly; a correctly written for loop will not overflow the bounds of an array. I think we'd have to see your code to know for certain; you are probably not alowed to show us any code.
OutofBounds exceptions w. . .
I haven't got the time to explain λs; that would take an hour or so, but λs are very nice to use and not at all difficult once you have grasped the concept. Find yourself a book like Urma Fusco and Mycroft Java8 in Action/Java8 and 9 in Action/Modern Java in Action (Manning 2015/2017) (=different edtions of the same thing with different names), and read chapter 3.
Yeah, I've never even heard of Lambda codes . . .
Trial and error won't work and that's that. You can try 1,000,000× and some of your atempts will be correct. Identifying thse attempts is the real problem. If you are using objectss and a Comparator, you only need one change:-Challenge: find out what happens if you change <= to < in line 17.
. . . trial and error more than anaylsis of the code
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton