Skip to content
Advertisement

Tag: arrays

Detecting last character

Im trying to detect whether the last character of a string contains an operator using an array checker that was previously used for integers. For some reason the code will always display “Not In” Even …

Why my IF can’t get some of my ArrayList’s indexes?

My idea here is to check whether the elements of my ArrayList start with A, B, C, or with another letter, but for some reason, my IF can’t get some words, such as “Almofada”. Output Answer Your issue is with your for loop. You are incrementing the index ‘i’ on each iteration of the loop, then removing the word at

Java 14 records and arrays

Given the following code: It seems, obviously, that array’s toString, equals methods are used (instead of static methods, Arrays::equals,Arrays::deepEquals or Array::toString). So I guess Java 14 Records (JEP 359) don’t work too well with arrays, the respective methods have to be generated with an IDE (which at least in IntelliJ, by default generates “useful” methods, i.e. they use the static

Printing a snake pattern using an array

I’m having trouble with an assignment where we are required to print out this array: My code is somewhat correct but it is not printing 10 and 19 where it should be. My output: My code: Can anyone detect what is causing the error? Any help would be appreciated. Answer This will generate the “snaking” pattern you described. It could

Advertisement