954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

operator ! cannot be applied to java.lang.String

hi,

i receive an error on this line -- if (salesPersonsName

Fenerbahce
Junior Poster in Training
62 posts since Apr 2006
Reputation Points: 15
Solved Threads: 0
 

you can't negate a String, only a boolean.
I've no clue what you're trying to accomplish there so can't help you out.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

Are you trying to say "not less than", if so why don't you just say "greater than"?

>
// instead of
<!


Edit: Nevermind, I'm an idiot, they're Strings so greater than and less than are not what you want anyway. Doh!

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

if you want to compare strings use compareTo() method ex: oneString.compareTo(anotherString). if oneString is greater then anotherString the method will return value >0, it it is less --> value <0, and if they are equal -->value =0.

I hope that this will help you.

Cao

eniacad
Newbie Poster
5 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

I knid of doubt that will help though, as the majority of peoples names (as the variable implies that that that is) will not be alphabetically less than end. What the OP probably wants is if (!salesPersonsName.equals("end")) . And this thread is bit old, anyway. I doubt the OP is still looking for a solution.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 
I knid of doubt that will help though, as the majority of peoples names (as the variable implies that that that is) will not be alphabetically less than end. What the OP probably wants is if (!salesPersonsName.equals("end")) . And this thread is bit old, anyway. I doubt the OP is still looking for a solution.


I guess I'm missing something here. Unusual for you to reply an old thread. Did somebody posted something? Did any moderator moved anything?

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

Someone must have moved something, or something, as this popped up in my mail as if it had been replied to, and now that I look at the post above mine, I realise that that post is old too, I had just assumed it was just posted. ;-) Ah well, sheet happens.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You