LaikaLaikakaLevel 32, United States of America, United States
21 March 2025
For the you need to replace the program functionality exercise, do we count space and non letter character when calculating number of character? If we do, shouldn't "forty one" be odd? If we don't, shouldn't "j r" be even?
max and min has a validator issue. I was getting the correct output but I set max = Integer.MIN_VALUE and in their solution they just set both to the first element of the array. My solution worked but their validator didnt like it for some reason.
in the maximum and minimum numbers task, there's no reason not to determine the max and min in the same loop in which they are entered, yet the validator doesn't like it :/
I've had the same problem, that's because if you remove an item at index 0 then all the other items get shuffled to the left, so the item that was previously at index 1 is moved to index 0 etc. I bypassed it by iterating back to front, then removing items from index i of i was smaller than m :)
Justin SmithLevel 41, Greenfield, USA, United States
11 July 2021
"Be sure that you just display the array in reverse order. You don't need to reverse the order of the elements in the list."
I don't understand this bit. How do you display an array (or arraylist) in reverse order without reversing the order of the elements? That sounds a bit like saying "paint the house red, but you don't need to paint the house red."
Justin SmithLevel 41, Greenfield, USA, United States
11 July 2021
Just checked if they mean the counting order of the numbers entered, no they do not mean that. I have no idea what this task wants me to do.
Think about how you are looping through arrays currently. Usually from start to finish. But you can also loop through the other way around by adjusting the for loop variable.
That just means displaying the elements from the last. That is the last element in the array is displayed first followed by the second last element and so on. You just need to loop through the array in reverse order. Consider this:-
int [] arr = {1,2,3,4,5};
for(int i = arr.length - 1; i >=0; i--)
System.out.print(arr[i]);
This prints 5,4,3,2,1.
task0719 (Display numbers in reverse order) caveat: you will get failed if you use anything other than an ArrayList<Integer>, even though that requirement is not stated anywhere and this is not really an appropriate structure for the job.
Cat code won't compile exercise gives
java.lang.NullPointerException even when I download the correct solution and it passes testing.
I tried while(true){
String name = reader.readLine();
int age= Integer.parseInt(reader.readLine();
int weight=Integer.parseInt(reader.readLine();
int tailLength=Integer.parseInt(reader.readLine();
then pass these values to the constructor.
But it keeps giving me NumberFormatException
Don't know what is wrong with this but got an answer that I am trying to convert null to int.
GO TO FULL VERSION