
-----------------------------------
Donny
Tue Apr 19, 2011 5:19 pm

String does not contain?
-----------------------------------
if (button == right && msg.contains(k));

I have this in an if statement, now i want something that will check for anything but that, how can this be achieved?

-----------------------------------
Tony
Tue Apr 19, 2011 5:22 pm

RE:String does not contain?
-----------------------------------
http://en.wikipedia.org/wiki/De_Morgan's_laws

-----------------------------------
Donny
Tue Apr 19, 2011 5:26 pm

RE:String does not contain?
-----------------------------------
This isn't a school project or anything so a little actual advice would help, I don't feel like reading this whole article. It doesn't even have code snippets.


EDIT: sorry for my rudeness and stupidity, i'm ill and not in a good mood, i just figured it out.. != infront instead of &&..

-----------------------------------
Tony
Tue Apr 19, 2011 5:33 pm

RE:String does not contain?
-----------------------------------
It's was like the very first thing on the page

NOT (P AND Q) = (NOT P) OR (NOT Q)

P := button == right
Q := msg.contains(k)

so you want
good programs requires a lot of reading.

-----------------------------------
Donny
Tue Apr 19, 2011 5:37 pm

RE:String does not contain?
-----------------------------------
Ya, i figured as much I just wasn't in the mood, and the way I did it didn't work out, instead of && i put != when I didn't know you could just put ! to negate something, and it would move my chars (over a network) in opposite directions somehow lol


EDIT: Also, how can i trim strings? I want to take 59021 : right and trim it down to just 59021, do you know how to do this?

-----------------------------------
SmokeMonster
Thu Apr 21, 2011 12:02 am

Re: String does not contain?
-----------------------------------
Use the trim function. http://download.oracle.com/javase/1.3/docs/api/java/lang/String.html#trim%28%29

-----------------------------------
Insectoid
Thu Apr 21, 2011 9:45 am

RE:String does not contain?
-----------------------------------
That's not exactly what he was going for.

Use a string tokenizer. I dunno how it works in Java, but it certainly exists. Use a colon (Or, a space followed by a colon) as the delimiter and take the first token.

-----------------------------------
Tony
Thu Apr 21, 2011 11:02 am

Re: RE:String does not contain?
-----------------------------------
Use a string tokenizer. I dunno how it works in Java
Java's Scanner class can take a custom delimiter and tokenize the input.
