Java substring a local variable inside a while loop

前端 未结 3 1207
余生分开走
余生分开走 2021-01-24 10:41

I have been trying to construct a while loop for looping through a string when it contains a \'pattern\' i\'m looking for. The string is a local variable, declared just above th

3条回答
  •  心在旅途
    2021-01-24 11:23

    Strings are immutable. That means that substring does not modify the string itself, but returns a new string object. So you should use:

    modifiedOnlineList = modifiedOnlineList.substring(tempFirstOccurence + 2);
    

提交回复
热议问题