problems with Arrays.binarySearch

Discussion in 'Plugin Development' started by SonnyX, May 8, 2011.

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

    SonnyX

    I have a small piece of code wich only gives a error when trying to find the last array:
    Code:
                      String[] anArray;
                      anArray = new String[15];
                      anArray[0] = "Chicken";
                      anArray[1] = "Cow";
                      anArray[2] = "Creeper";
                      anArray[3] = "Ghast";
                      anArray[4] = "Giant";
                      anArray[5] = "Monster";
                      anArray[6] = "Pig";
                      anArray[7] = "PigZombie";
                      anArray[8] = "Sheep";
                      anArray[9] = "Skeleton";
                      anArray[10] = "Slime";
                      anArray[11] = "Spider";
                      anArray[12] = "Squid";
                      anArray[13] = "Zombie";
                      anArray[14] = "Wolf";
    
                      int i = Arrays.binarySearch(anArray, "Wolf");
    
    This will result i = -14
    while it should be i = 14 anybody knows why?
    if wolf was Zombie or any other from the list it works fine.
    If any of you needs the full source, say so :)
     
  2. Offline

    nisovin

Thread Status:
Not open for further replies.

Share This Page