• Post Reply Bookmark Topic Watch Topic
  • New Topic

"The value of the local variable line is not used" in try with resources block  RSS feed

 
Ranch Hand
Posts: 43
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Getting The value of the local variable line is not used for "line". No idea what I'm doing wrong here??

 
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The message literally says what's wrong. You declared a variable called line, but you never use it, you only assign a value to it.

The warning is intended to prevent bugs in your program. It did its job well, because I don't think you intended to read two lines per loop iteration.
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another thing is that your loop is written incorrectly. It might have been correct had you used line.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!