Remove Superfluous Comments

 class​ Inventory {
»// Fields (we only have one)
» List<Supply> supplies = ​new​ ArrayList<>(); ​// The list of supplies.
 
»// Methods
 int​ countContaminatedSupplies() {
»// TODO: check if field is already initialized (not null)
 
»int​ contaminatedCounter = 0; ​// the counter
 // No supplies => no contamination
»for​ (Supply supply : supplies) { ​// begin FOR
 if​ (supply.isContaminated()) {
» contaminatedCounter++; ​// increment counter!
» } ​// End IF supply is contaminated
» }​// End FOR
 
»// Returns the number of contaminated supplies.
»return​ contaminatedCounter; ​// Handle with care!
  }
»} ​// End of Inventory class

You’ve probably heard that comments are very important. They are, ...

Get Java By Comparison now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.