Java Pig Latin sentence translator using Queues

坚强是说给别人听的谎言 提交于 2019-12-08 14:24:24

You are not resetting index to 0 before entering your second while loop. Since index == message.length() after the first loop ends, the second loop terminates immediately.

Edit: Re: Your latest update.

In your second loop you only dequeue the first message.length() characters from the word queue. If you've added -ay to the end you won't see it. Instead, loop on the length of the queue, not the length of the input message:

while (!word.empty())
    System.out.print(word.dequeue());

I can spot numerous other issues with your logic (you are not removing the first letter and you are not processing individual words in the sentence), but the above changes should be enough to get you printing what's on the queue and send you on your way debugging.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!