Hello!
I am making quizes in Moodle with use of Code Runner for Java. I have a question regarding how should the line in a test case for checking an output of the method, that returns an array, should be filled in? For example the task is following:
Given an array of ints, swap the first and last elements in the array. Return the modified array. The array length will be at least 1. swapEnds([1, 2, 3, 4]) → [4, 2, 3, 1] swapEnds([1, 2, 3]) → [3, 2, 1] swapEnds([8, 6, 7, 9, 5]) → [5, 6, 7, 9, 8] In answer box preload I have following: |
} |
And in the line for text case I write following:
int [] nums=new int [] {1, 2, 3, 4};
System.out.println(Arrays.toString(swapEnds(nums)));
In this case I get a response, complaining regarding Arrays.
I tried to import java.util.Arrays , but it is not working either.
Howshould it be done in a wright way?