I tried to do this in my class:
public void replaceWord(String app, String rep)
{
while (input.hasNext())
{
String word = input.next();
System.out.println(word);
}
}
but why doesn't it work??
I tried it with:
public int getNumberOfWords()
{
int n = 0;
while (input.hasNext())
{
String word = input.next();
n++;
}
return n;
}
and it works.
My purpose here is to print out every single word on my input
2006-10-27
04:18:52
·
2 answers
·
asked by
?
1
in
Computers & Internet
➔ Programming & Design
input is a scanner
I declared private Scanner input;
at the top
2006-10-27
04:51:55 ·
update #1