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