I'm taking a CS course and this code is giving me problems.
while (statScan.hasNext()){
currentStat = statScan.next();
if (currentStat = h);
{
hStat++;
}
System.out.println("" + currentStat);
Look at the "if" statement. Java says "cannot convert string to boolean" and from my understanding boolean is a true/false sorta thing so what Java isn't understanding is how to evaluate and compare the strings. How do I force it to do so?
the problem is that you assign it instead of ask if it's equal (assign '=', equals '==')
this is the solution for that line:
also if it's strings use .equals()
if (currentStat.equals(h))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With