java - The value of the local variable word is not used -


I have a way in which a scanner is in the form of a parameter, the purpose of the method is to calculate the number of words in a file Do it and have to return that number. Here's the method:

  Public Static Inter WordCount (Scanner InputFile) FontNoteFound Actions {int wordCount = 0; While (inputFile.hasNext ()) {string word = inputFile.next (); Word count ++; } Return password; }   

The method works fine, but I "do not use the value of the local variable" warning which I would like to get rid of I understand why I am getting a warning, however, as far as I know, I need

  string word = inputFile.next ();   

To move the pointer through the file. I can suppress the warning, though, I think that I am probably trying to do. I can use only the scanner class to read the file.

What you're doing is okay, but warnings are given because you only the word < / Code> and can not read it anyway, instead of just saving the results, leaving the assignment and just try using inputFile.next () .

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -