This question already has an answer here:
- How do I compare strings in Java? 23 answers
So i have this if statement that checks if a message received from irc, split at the first " " equals "add". The whole message is ";quote add test quote", here is the code.
if(event.getMessage().startsWith(";quote")){
File quotecheck = new File("quotes.ini");
if(event.getMessage().contains(" ")){
event.respond(event.getMessage());
event.respond("Message Contained Space Key");
if(event.getMessage().split(" ").length > 0) {
event.respond("Split longer than 0");
if(quotecheck.exists()){
event.respond("Quotecheck Existed");
Wini quotes = new Wini(new File("quotes.ini"));
String totalQuotes = quotes.get("Quotes", "totalQuotes");
int totalQuotesInt = Integer.parseInt(totalQuotes);
event.respond(event.getMessage().split(" ")[1]);
if(event.getMessage().split(" ")[1] == "add "){
event.respond("Split One Equalled add");
int nextQuoteInt = totalQuotesInt+1;
String nextQuote = Integer.toString(nextQuoteInt);
quotes.add("Quotes", nextQuote, event.getMessage().split(" ")[2]);
}
}
}
}
Also, the if that's failing is at line 14
EDIT: This question is different from this question because its im asking why it ISNT working, not how to compare strings
Aucun commentaire:
Enregistrer un commentaire