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

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

  •  04-07-2023
  •  | 
  •  

Domanda

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
        }
È stato utile?

Soluzione

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
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top