Question regarding the character ? in return statement

Viewed 26

I am trying to find the last common element of two different lists and return the index at which it is located. My book uses the method below to do this. However, I don't know exactly what the last line, i.e. the return statement, is supposed to mean, especially the "?" because i havent seen it before.

    private int getIndexOfFork( Chain previousChain, Chain chain )
    {
        int index = -1;

        for(int i = previousChain.size() - 1; i >= 0; i--)
        {
            index = chain.getChain( ).indexOf( previousChain.get( i ) );
            if ( index > -1 )
            {
                break;
            }
        }

        return ( index > -1 ) ? (index + 1) : 0;
    }
0 Answers
Related