How to print several strings backwards in Java

后端 未结 3 2015
青春惊慌失措
青春惊慌失措 2021-01-14 09:37

I am trying to take a file full of strings, read it, then print out a few things:

  • The string
  • The string backwards AND uppercase
  • The string len
3条回答
  •  情书的邮戳
    2021-01-14 09:59

    Where are you declaring the String backwardsWord?

    If you don't clear it between words then the memory space allocated to that string will still contain the previously added characters.

    Make sure you are tossing in a backwardsWord = ""; in between words to reset it's value and that should fix your problem.

    Without seeing more of your code I can't tell you exactly where to put it.

提交回复
热议问题