0

Compilation error but does not say anything else...

https://code.sololearn.com/cPjdfw2R7wv7/?ref=app This code above takes in a number and returns a Boolean value whether it is a prime number or not. Or at least it's supposed to. The problem is, I get an error. Compilation error ...and nothing else. What an I doing wrong and why doesn't the compiler spit specific errors?

9th May 2018, 8:16 AM
eagleblood
7 Antworten
+ 8
tadashi akahori First of all, Java has nothing like Int. int is a primitive data type contained in the Integer wrapper class. the boolean variable ans should be a global (instance) variable as you're using it in two different methods. for loop must have the following prototype: for(initialization; condition; iteration) * Check the semi-colons right there ;) You forgot to give the findPrime method the boolean return type.
9th May 2018, 8:49 AM
Dev
Dev - avatar
+ 5
i assumed you copied the code from your ide to code playground?if so i would suggest to copy from the line of the main method leaving the class declaration just type it manually in the code playground
9th May 2018, 8:23 AM
)_)
)_) - avatar
+ 4
There are a lot of syntax errors and bugs. Here is the working code: https://code.sololearn.com/cpaAWTaUQBJ4/?ref=app I hope you'd find them yourself 😏
9th May 2018, 8:37 AM
Dev
Dev - avatar
+ 1
Disorder🚸🔭🌎 no, I typed it straight into the editor, and Dev thanks a lot! I'll look at the bugs.
9th May 2018, 8:39 AM
eagleblood
+ 1
Dev thanks man! I didn't know that int arrays were done with "int", not the class name "Int". So, the variables cannot be accessed from the outside?
9th May 2018, 8:43 AM
eagleblood
+ 1
Dev thanks so much!!
9th May 2018, 8:50 AM
eagleblood
+ 1
One suggestion: I have noticed this also (compilation error without info) on SL... When it happen, try your code on others online code editors
9th May 2018, 8:59 AM
KrOW
KrOW - avatar