Sums of nextInt for file input
How can I modify this part of my code so that "token" would be the previous number the program input from the text file and the current number? For example, there is 2 number inside the text file, the 1st = 2 and the 2nd =4 , how can I make "token" be the sum of these two? Thanks
Code :
while(inFile.hasNextInt())
{
token =+ inFile.nextInt();
System.out.println(token);
winCounter++;
}
Re: Sums of nextInt for file input
What's wrong with the code you are currently showing?
Re: Sums of nextInt for file input
"token" will be the last integer that the hasNextInt() find instead of the sum of the previous one and the current one. What I'm trying to do is make "token" be the sum of all the number the hasNextInt() find
Re: Sums of nextInt for file input
Perhaps you want to change =+ to +=.