11 AnswersNew Answer
Based on the error output I think it might name the file based on the first class you declare, but if the very first thing is an enum it doesn't like it, it's expecting a class. The error you get with the enum first is "duplicate class Answers" suggesting that Answers is defined as a class and an enum. This would only be an artifact of how sololearn's compiler works (because normally a public java class must be defined in a file of the same name) so my guess is it's inserting a class when you declare an enum first
also, take note, that you cannot provide multiple inputs on sololearn playground only once, when you first run the code. if your logic contains user input after the prior input was handled in some way, it won't be possible to do that. this is the sad part of sololearn. another sad story is that you can use only the built-in packages. if you want to use something external, it's possible only if you can install the package during runtime. you can do that in python using the subprocess module, but I don't know of a certain way in java
Minho oh i know what you mean. what's up with the weird quirks. no worries you'll get used to it 😆 same happens with js. say, i have a literal object saved in a variable which i will use eventually in the code. i usually keep those as constants at the bottom of the file. no IDE has ever complained about such a thing, but here i have to move them on top in order to be recognized by sololearn compiler/interpreter
Sebastian Pacurar I'm not taking multiple inputs here. I even commented out the input part. I think it's something to do with how SL compiler works maybe..
Sebastian Pacurar run this code now.. it works.. But now question is why and how it works now and didn't work previously.
Sebastian Pacurar 😆 Great! Thanks for your answer!
Odyel yeah! It works fine for me as well in IDE but not here.. That's why I was curious to know the reason why it's not working here.. Thanks for your answer.
Dan Walker Yeah! You're right! It's working that way 😅 Thanks for your answer.
Dan Walker Yeah! You might be right.. Thanks again for your answer :)
It's a bug. Just put this into my computer and it works just fine
Moving the enum declaration to the bottom solved it for me, not sure why that worked. Must be something to do with the way sololearn's playground works