The code not listed has an arraylist named unsorted size 1000, and another array named keys_Array, size 100. Every element from the keys_Array was picked from the unsorted, so they should always be found.

Problem I'm having is that it doesn't print anything. It just reports a msg from the IDE

Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)

Its suppose to search for the element in the first key index, find it and report the position, then move to the second, ect ect until the last element.
I realise it will be a poor looking output with 100x lines, but this is for testing.

If you know what i'm doing wrong, tell me please!
:)

for(int z = 0; z < 100; z++){ // Search 100 times (same size as keys_Array
            int x=0;
            boolean found = false;

            // Search for key_Array elements (100 of them) inside unsorted and report position
            // The elements have to be there, so the else part of the statement is really needed
            // But it helps me for testing.
            while (!found && x<1000)
                if (unsorted.get(x)==keys_Array) // I'm almost positive this here 
                    found=true;                  // is wrong, with the keys_Array part,
                else                             // I tried to make it// increment,
                    x ++;                        // but wasn't sure how.
            if (found)
                System.out.println("Found in position " + x);
            else
                System.out.println("The number is not found");
        }
    }
}
while (!found && x<1000)
                if (unsorted.get(x)==keys_Array[c])
                    found=true;
                else
                    x ++;
                    c ++;

I think I just need to know what to change here, both x and c are set to 0 at the start.

Says it is incompatible types :(

Solved ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.