How do i do an if statement about chars?
The if statements are what is annoying me.
public class chars
public static void main( String args )
Scanner input = new Scanner(System.in)
System.out.println( "What is your name?" );
name1 = input.next();
[B] if ( name1 = Jerry )[/B]
points1 = points1 + 1;
System.out.println( "Whats your opponents name?" )
name2 = input.next();
[B] if ( name2 = CPU )[/B]
points2 = points2 + 1;
I cant make it so it'll take the char....
Have you tried something like:
oh darn, srry i tried that but forgot the () around jerry, but shouldn't there be another way to do that?
also how would i do a defult, like make the defult Jerry so the user would have to delete the chars?
Don't you mean to use == rather than =?
Originally Posted by whosadork
Even C doesn't do the comparison with a single equal
you cant compare strings with ==
use compareTo or equals method.