I’m currently learning Java.
I have a for loop which uses a counter to keep track of how many words are written on a line.
When the wordCount == 10, I insert a line break System.out.println()
I want to reset wordCount to zero after this line break, but redeclaring wordCount == 0 is “not a statement” in NetBeans. How do I reset a variable value? Thanks
Yeah u can add a condition :
if ( wordcount ==10)
wordcount =0;
This will reinitialize wordcount to 0, when it becomes 10. Hope it helps.
We use ‘==’ during comparison and ‘=’ for assigning values.