The code should be exactly the same. Am I missing ...
# getting-started
j
The code should be exactly the same. Am I missing something?
d
Hmm, it doesn't help that some variable names are different. But I think the first if statement is different.
Nvm, it's fine. The last
else if
is different.
m
Agreed on both points. 'Else' in kotlin is adding 2 whereas Java is adding 1 in condition. Did you try using converter in Intellij for first take? This assumes you use Intellij as your editor of course.
j
🤦‍♂️
Thanks. Didn't see that one there....
d
Also,
Array<Int>
is not
int[]
. You actually want
IntArray
.
j
Ah ok
I'm not using Intellij btw. It's hacker rank's editor.
m
Array<Int> is like Integer[] in Java. Works fine but not efficient. so yes, if dealing with primitives, favour the specific classes as the compiler will 'do the right thing' for you. Did you try the converter? As it should have also 'done the right thing' with minimal effort on your part.
j
I'll look into the converter. Thanks