samedi 13 juillet 2019

If else loop iterating even though the conditions arent met

suppose message = "weather in paris,fr" the if else will go through

if message = "weather" it is still going through

why is that so? I feel like i am not noticing something.

i tried && in the if and putting "in" || "at" but it didnt work either

String location = "";

            if ((message.contains("weather") || message.contains("Weather"))) 
            {
                if (message.contains("in") || message.contains("at"))
                {
                    try
                    {
                        location = removeTillWord(message, "in");
                        location = location.replaceFirst("in", "");
                        System.out.println(location);
                        sendMessage(channel, API(location));
                    } 
                    catch (ParseException e) 
                    {
                        e.printStackTrace();
                    }
                }
                else
                {
                    sendMessage(channel, "Please enter location.");
                }

            } 
else if... else.. etc

it should skip the loop but its not doing that

Aucun commentaire:

Enregistrer un commentaire