Missing return statement | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Missing return statement

https://code.sololearn.com/cZRKYp43ByUp/?ref=app The code checks if a string is 'prime' Line 52 missing return statement. But i do have one return statement within the function scope.

31st Jul 2018, 2:18 PM
Ahan
3 Answers
0
Yeah, if flag is 1, but if it isn't? there's no return, you gotta cover al possible options
31st Jul 2018, 2:44 PM
voidneo
0
Thank you for your help. But still my code is flawed and i cant comprehend the error. Could you help me out again? i tried looking up nullpointerexception on the Internet but couldn't understand a thing
31st Jul 2018, 4:12 PM
Ahan
0
the problem id at line 33. What happens is that, the code inside classes is executed when you run the.program, even if you don't create am object, so you assign l the length of str, but str hasn't been initialized. this has 2 solutions(maybe more). You initialize Stringop variables with some value or, you assign l the length inside the method stringprime
31st Jul 2018, 4:30 PM
voidneo