Implement a static main(String[]) method that populates the array variable with the values valueStart and valueEnd.
If the length of the array is even, then its first half must be filled with valueStart values, and the second half with valueEnd.
If the length of the array is odd, then fill the large
Filling an array
- 6
Locked
Comments (6)
- Popular
- New
- Old
You must be signed in to leave a comment
Hiyo Full Stack Developer
17 January, 07:38
0
Vadim “迪姆哥”
12 October 2022, 19:43
Please correct the validator of the code!
This task could be past only if:
When array size is odd, startValue must fill by array.length +1;
As the task requires:
When array size is odd, fill LARGER part with valueStart!
For example, if I try to fill first part of array with valueStart by "array.length * 0.8" (80% of array) - which technicly is larger part,
validator didn't give it pass....
0
Ace Phelps
30 April 2022, 07:36
idk whats going on but heres my code what did i do wrong i dont get it
if (array.length % 2 == 0) {
Arrays.fill(array, 0, array.length/2, 10);
Arrays.fill(array, array.length/2, array.length, 13);
System.out.println(Arrays.toString(array));
}
if (array.length % 2 != 0) {
Arrays.fill(array, 0, array.length, 13);
Arrays.fill(array, array.length/2, array.length, 10);
System.out.println(Arrays.toString(array));
}
+1
Ace Phelps
30 April 2022, 07:36
Error:
Implement the main(String[]) method in accordance with the task conditions.
0
Ace Phelps
30 April 2022, 07:50
ok i was confused by second step about larger part now i got it (larger part is more then half)
0
Lisa
9 January 2022, 09:22
I do not know the task and I can not open its description. If you're looking for answers the best way is, to attach your existing code. That way everyone can read the task description and what you came up with so far.
0