Skip to content
← Back to Community
Int cannot be converted to int[] (JAVA)
Profile icon
paulluch

it gives me the error: exit status 1
UnitTests.java:11: error: incompatible types: int cannot be converted to int[]
int[] solution = Main.candyCalculator(108);
And i don`t know how to fix it.
If someone can help, I just started programing with JAVA
Sometimes works but when I want to submit the task it gets the error that I said.

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Profile icon
paulluch
Comments
hotnewtop
Profile icon
Coder100

Hi! The problem is int[] is an array and your function only returns an int. So have your code like this:

int solution = candyCalculator(108);
Profile icon
paulluch

Thank you so much!

@Coder100

Profile icon
Coder100

no problem!!

@paulluch

Profile icon
PattanAhmed

@paulluch
Hi Pau,
I think changing this line of code may work,

int solution=candyCalculator(108);

Just change/keep this line of code.

Hope this helps
Please mark my answer if this helps.

Profile icon
paulluch

I will look forward this page, thank you!!

@PattanAhmed

Profile icon
PattanAhmed

@paulluch
Welcome!
Glad you got helped!
Please mark my answer if this helps

Profile icon
DynamicSquid

it seems to be working fine...

Profile icon
k9chelsea2

please only post something once just add the repl or edit the first post