EqualsIgnoreCase

Discussion in 'Plugin Development' started by KoolzSkillz, Nov 1, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    KoolzSkillz

    How would their be a better way to do this

    } if (EiC.equalsIgnoreCase("3") || EiC.equalsIgnoreCase("4") || EiC.equalsIgnoreCase("5")) {

    so it does it if it is 3+
     
  2. KoolzSkillz
    Attempt to convert the string to an int with Integer.parseInt(string), then check if that is more than 3.
    Code:
    int n = Integer.parseInt(EiC);
    Wrap it around a try/catch block.
     
  3. Offline

    Konato_K

    So you're trying to get it for all the values that are more than 3?

    Why don't you make it into an int with Integer.parseInt(String) (don't forget to catch) and just make an if(myNumber>=3) ...
     
    _Filip likes this.
  4. Offline

    teej107

    Or an alternative way would be rather than parsing ints, you convert ints to a string.
    PHP:
    for(int i 36i++)
    {
        if(
    something.equalsIgnoreCase(Integer.toString(i)))
        {
       
        }
     
    }
    No try catch statement needed.

    EDIT: Though if the number just needs to be 3 or above, then parsing ints would be better. My example was if you wanted a number from 3 to 5.
     
  5. teej107
    Problem is that the number 6 you have there is actually unknown, unless 5 is the max OP wants (he did say 3+ though).
     
  6. Offline

    mythbusterma

    teej107

    The other way is faster, and doesn't require string comparison...but it's insignificant.
     
Thread Status:
Not open for further replies.

Share This Page