New topic: comparing the contents of objects. Strings are objects. If you want to compare the contents of two objects you need to use the equals() method:
myPassword.equals( "XRay" )
Type: Posts; User: Norm
New topic: comparing the contents of objects. Strings are objects. If you want to compare the contents of two objects you need to use the equals() method:
myPassword.equals( "XRay" )
Please be more specific and not use words like this and it. I can't read your mind.
What are you trying to do in the if statement?
if ( s == XRay )
Where is the variable named: Xray defined? The compiler can not find its definition.
Also see post #16
Where is the variable named: Xray defined? The compiler can not find its definition.
If you had made either of the changes you should get a different error.
Please post the new code and the full text of the error messages.
The last line of your post encloses the s in "s "s"
This line defines the variable: thePassword as a boolean variable
boolean thePassword
What text are you using to learn java? These...
Is Xray the name of a variable? If so you need to define it and give it a value.
Or did you want it to be a String? If so enclose it in "s.
Take a look at these:
Equality, Relational, and Conditional Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)
The if-then and if-then-else Statements (The Java™...
You are using the assignment operator (=) instead of the comparsion operator (==).
The value returned by an assignment is what is to the left of the =.
An if statement requires a boolean value,...
Can you explain the problem?
If you take out the case for M, S or D you will also get the same thing when you enter an 'a'. The code for those other letters is not being used when you enter an 'a'.
Try entering an e (instead...
Can you explain what is wrong with what the program did when you executed it?
The output looks like the program did what it was supposed to do.
Can you post the contents of the console window that shows what you are talking about?
On windows: To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select...
Can you explain the problem? Are you getting error messages? Please copy and paste the full text here.
Please Edit your post and wrap your code with
<YOUR CODE HERE>
to get highlighting...