-
Code:
private void cheat_keyPress(Object source, KeyPressEvent e)
{
char c_char;
c_char = e.getKeyChar();
if(c_char == 13) {
String c_code;
String c_parse;
String c_get;
Form1 mon = new Form1();
long c_line;
c_code = cheat.getText();
c_get = c_code.substring(0,5);
if(c_get.substring(0,c_get.length()) == "money") {
c_parse = c_code.substring(6,c_code.length());
super.close();
c_line = Integer.valueOf(c_parse).intValue();
mon.addmoney(c_line,true);
cheat.setText(c_parse + "testing phase 1");
}
}
}
Whats wrong with this code? The second if wont execute, the first 1 will. ***!
-
Just a guess here...
Try:
if(c_get.substring(0,c_get.length()).compareTo("money")== 0)
or
if(c_get.substring(0,c_get.length()).toString().compareTo("money")== 0)
-
Ummmmm, your a ****ing genius!!!
:)
Ive been wondering how to solve this for a while now. I dont see why my code dint work in the first place, but yours works just as fine, thanks!
:D:)
Just 1 thing, why does compareTo have to eqaul 0?... i would think that if it finds a match it would want 1. And return 0 when it dosent, am i mixed up or am i totaly on the wrong track?
Anyways, thanks!
-
I don't know why it's like that.
Perhaps a match returns 0 as in no error rather than true/false...