![]() ![]() Chances are, it isn't, but the difference needs articulating, for sure. Let me know how you get on - I'd be interested to get to the bottom of what's causing the compiler to work differently than expected. ![]() But the reverse process may cause the problem I don't know. You can't use the console object in the IDE, easily, (you can, but it's a chore - I wrote a long post about it somewhere within these pages) so switching to a scanner makes sense. There are two ways to solve this problem. As you can see, like many real life problems, this is caused by misunderstanding between the user and the programmer. I do think that the expected use of the stream reader is part of the issue you're facing. When the third scanner.nextLine () is called, it finds the enter or newline character still existing in the input buffer, mistakes it as the input from the user, and returns immediately. However, if I had £10 for every post that states "it works fine in the IDE- the challenge must be wrong", I'd be a rich man! I'm not, unfortunately! Their outputs may be slightly different which is throwing the tests out - I don't know what those tests are, unfortunately. abcdefghijklmnopqrstuvwxyzS in the Auto activation triggers for Java field. It may be that the challenge tests are expecting the code to use a stream reader rather than a scanner. Complete your next line or function in context. That may lead you to understanding where your code isn't behaving itself. Use the Preview button to see what it is doing. Look at the output from your code in the challenge. Looking at your IDE and code isn't the issue. That throws another problem, as it's possible that word will never be assigned anything as it is hidden within the if conditional, so initialize that to a blank string where you declare it. ![]() Protect that in the way I suggested, using an if to test for hasNextLine(). That's around the use of scan.nextLine() I referred to in my earlier answer. The trace goes right back to the start of execution, in reverse order, so start with the first reference to your code, i.e. The stuff about Scanner.java:1540 can be ignored - I don't fancy rewriting that lot!! However, the earlier errors are in your code. Please enter first prompt: : No line foundĪt (Scanner.java:1540)Īt (Prompter.java:89)Īt (Prompter.java:69)Īt (Prompter.java:49)Īt (Main.java:15) Please enter the story, format placeholders with surrounding double underscore: _example_ Package com.teamtreehouse import java.io.* import import import import import import import import public class Prompter ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |