How to change this method so that it doesn't include inner assignments? [closed]

StackOverflow https://stackoverflow.com/questions/23118274

  •  04-07-2023
  •  | 
  •  

문제

I need to change this method so that checkstyle will stop complaining at me.

The inner assignment error is in the for each loop. I want the same functionality but without the error. Thanks!

        for (String line; (line = br.readLine()) != null;) {
            //CODE
        }
도움이 되었습니까?

해결책

Checkstyle doesn't like assignments inside other statements. You could change your for loop as follows:

for (String line = br.readLine(); line != null; line = br.readLine()) {
    // rest of your code
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top